Yes, you can ust it
OpenFileDialog[
^], but in different way, using string variable instead OpenFileDialog properties.
Please, create new WindowsApplication project and put one button on the form, then double-click on it. Copy and paste below code:
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim ofd As OpenFileDialog = Nothing
Dim sFullFileName As String = String.Empty
Try
ofd = New OpenFileDialog()
With ofd
.InitialDirectory = Environment.SpecialFolder.MyDocuments
.Multiselect = False
.DefaultExt = "txt"
.Filter = "txt files (*.txt)|*.txt"
If .ShowDialog = Windows.Forms.DialogResult.Cancel Then Exit Try
sFullFileName = .FileName
End With
MsgBox("Directory name: '" & System.IO.Path.GetDirectoryName(sFullFileName) & "'" & vbCr & _
"Short file name: '" & System.IO.Path.GetFileName(sFullFileName) & "'", MsgBoxStyle.Information, "Information...")
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Exclamation, "Error...")
Finally
ofd = Nothing
End Try
End Sub
End Class