The above code will open the selected file with a Stream, allowing you to read the content of the file. If you don't need to read the content of the file, you can remove the myStream code and simply use openFileDialog1.FileName to get back the name of the selected file.
Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged Dim myStream As IO.Stream Dim openFileDialog1 As New OpenFileDialog()
openFileDialog1.InitialDirectory =
"c:\"
openFileDialog1.Filter =
"exe files (*.exe)|*.exe|All files (*.*)|*.*"
openFileDialog1.FilterIndex = 2
openFileDialog1.RestoreDirectory =
True If openFileDialog1.ShowDialog() = DialogResult.OK Then
myStream = openFileDialog1.OpenFile()
If Not (myStream Is Nothing) Then ' Insert code to read the stream here.
Opening
northern
http://msdn.microsoft.com/library/default.asp url=/library/en-us/cpref/html/frlrfsystemwindowsformsopenfiledialogclasstopic.asp
Christopher
Best regards,
Karen Chen
Im using this code for the openfiledialog:
Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged Dim myStream As IO.Stream Dim openFileDialog1 As New OpenFileDialog()
openFileDialog1.InitialDirectory =
"c:\"openFileDialog1.Filter =
"exe files (*.exe)|*.exe|All files (*.*)|*.*"openFileDialog1.FilterIndex = 2
openFileDialog1.RestoreDirectory =
True If openFileDialog1.ShowDialog() = DialogResult.OK ThenmyStream = openFileDialog1.OpenFile()
If Not (myStream Is Nothing) Then ' Insert code to read the stream here.myStream.Close()
End If End If End SubBut does it mean by:
' Insert code to read the stream here.