Question: Simple utility to get a file for use.

Using openfiledialog I am trying to get the full path EG: File = text1.txt and it is located in c:\temp. So the full path is C:\temp\text1.txt.

But all I can get is the file name. I've searched I've hunted, I'e tried for a couple of hours and nothing works.

Here is code with comments...

```
'open the openfile dialog so the user can search for a file
        Dim openFileDialog1 As New OpenFileDialog()
        'set the root to the z drive
        openFileDialog1.InitialDirectory = "Z:\"
        'make sure the root goes back to where the user started
        openFileDialog1.RestoreDirectory = True
        'show the dialog
        openFileDialog1.ShowDialog()

        'check there is something to work with... the user did not exit before selecting a file etc.
        If openFileDialog1.FileName.Length = 0 Then

            'if the user selected a file set the value of the replacefile text box
        Else
            TB_ReplacementFile.Text = System.IO.Path.GetFullPath(openFileDialog1.FileName)

        End If

```

All I get is the file name...

Answer: 
The [FileName Property](https://msdn.microsoft.com/en-us/library/system.windows.forms.filedialog.filename(v=vs.110).aspx) returns the full path.

> 
> The file name includes both the file path and the extension. If no files are selected, this method returns an empty string ("").
> 
> 
> 

```
If (openFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK) Then
    TB_ReplacementFile.Text = openFileDialog1.FileName
End If

```
Not 100% sure if this would resolve the issue you're having, or if it's simply just another way to handle it, but I prefer to check the DialogResult. I.E:

```
Dim openFileDialog1 As New OpenFileDialog()

openFileDialog1.InitialDirectory = "Z:\"

openFileDialog1.RestoreDirectory = True

If openFileDialog1.ShowDialog = System.Windows.Forms.DialogResult.Ok Then
    Console.WriteLine(openFileDialog1.fileName)
End If

```