Represents a common dialog box for selecting or opening a file.
The OpenFileDialog class has properties for setting the initial appearance and functionality of the file dialog box, a property for returning the filename or names selected by the user, as well as a method for showing the dialog box. An instance of the OpenFileDialog class does not itself open the file, but instead provides the information that allows your code to do this programmatically.
Under VB, the most common use for this dialog box is to get the name of a file from the user, after which we can use VB’s functions to open that file.
An OpenFileDialog object can be instantiated as follows:
Dim oOpenDlg As New OpenFileDialog
The following is a brief description of some of the more important members of the OpenFileDialog class:
Gets or sets a Boolean value that
determines whether the default file extension is automatically added
to the Filename property if the user fails to enter an extension. Its
default value is
Sets or retrieves a Boolean value
indicating whether a warning message should be displayed if the user
enters the name of a file that does not exist. The default value is
Gets or sets a String that defines the default file extension. The string should consist of the file extension only without a period.