![]() ![]() | ||
As discussed in the In Depth section of this chapter, Open File dialogs let you get the name or names of files to open from the user. They're based on the OpenFileDialog class, which has this class hierarchy:
You can find the notable public properties of OpenFileDialog objects in Table 9.9, the notable public methods in Table 9.10, and the notable public events in Table 9.11.
Property |
Means |
---|---|
AddExtension |
Gets/sets if the dialog box adds an extension to file names if the user doesn't supply the extension. |
CheckFileExists |
Gets/sets if the dialog box displays a warning if the user specifies a nonexistent file. |
CheckPathExists |
Gets/sets whether the dialog box displays a warning if the user gives a path that does not exist. |
DefaultExt |
Gets/sets the default file extension. |
FileName |
Gets/sets the file name selected in the file dialog box. |
FileNames |
Gets the file names of all selected files. |
Filter |
Gets/sets the current file name filter string, which sets the choices that appear in the "Save as file type" or "Files of type" box. |
FilterIndex |
Gets/sets the index of the filter selected in the file dialog box. |
InitialDirectory |
Gets/sets the initial directory used in the file dialog box. |
Multiselect |
Gets/sets whether the dialog box allows multiple file selections. |
ReadOnlyChecked |
Gets/sets whether the read-only checkbox is checked. |
RestoreDirectory |
Gets/sets whether the dialog box should restore the original directory before closing. |
ShowHelp |
Gets/sets whether the Help button should be displayed. |
ShowReadOnly |
Gets/sets whether the dialog displays a read-only check box. |
Title |
Gets/sets the file dialog box title. |
ValidateNames |
Gets/sets a value specifying if the dialog box accepts only valid (that is, Win32) file names. |
Method |
Means |
---|---|
OpenFile |
Opens the file selected by the user, with read-only permission. The file is specified by the FileName property. |
Reset |
Resets all options to their default values. |
ShowDialog |
Shows the dialog box. |
Event |
Means |
---|---|
FileOk |
Occurs when the user clicks the Open or Save button. |
HelpRequest |
Occurs when the user clicks the Help button. |
![]() ![]() | ||