and also the OpenFileDialog has other userful properties such as the filter property wich allows to open a file in an specific format, i use it very often when i work with xml files.
That will show the dialog with only MP3 files being visible or select the All Files combo item in the dialog to view them all. Either way its just a simple example.
when i use your code for the openFileDialog the window comes up for the user to choose a file but after "OK" is clicked the windows close and the file does not open. i don't understand what i'm doing wrong. i'm very new to vb.net. please help!
The main purpose of the OpenFileDialog is to select a file and get the filename and path of the file the user selected. You can then do what it is you wanted to do with the file.
If you want to actually execute/open the file that the user selects, then try the code below...
----------------------
If OpenFileDialog.ShowDialog() = DialogResult.OK Then
Process.Start(OpenFileDialog.FileName)
End If
----------------------
You can also put the Process.Start(OpenFileDialog.FileName) code in the OpenFileDialog_FileOK event.
----------------------
Private Sub OpenFileDialog_FileOk(ByVal sender As System.Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles OpenFileDialog.FileOk
Process.Start(OpenFileDialog.FileName)
End Sub
----------------------
That event is fired if the user selects a filename. IF the user cancels or whatnot, then the _FileOK event will not fire.
Anyways, hopefully you understand how the OpenFileDialog works and what its main purpose is.