CommonDialog | +--FileDialogpublic abstract class FileDialog
Represents the abstract base class for the OpenFileDialog and SaveFileDialog classes.
Fields
Name | Description |
---|---|
ALLOWMULTISELECT | Specifies that the File Name list box allows multiple selections. |
CREATEPROMPT | If the user specifies a file that does not exist, this flag causes the dialog box to prompt the user for permission to create the file. |
EXTENSIONDIFFERENT | Specifies that the user has typed a filename extension that differs from the extension specified by the DefaultExt property. |
FILEMUSTEXIST | Specifies that the user can type only names of existing files in the File Name entry field. |
HIDEREADONLY | Hides the Read Only check box. |
NOCHANGEDIR | Restores the current directory to its original value if the user changed the directory while searching for files. |
NODEREFERENCELINKS | Directs the dialog box to return the path and filename of the selected shortcut (.LNK) file. |
NONETWORKBUTTON | Hides and disables the Network button. |
NOREADONLYRETURN | Specifies that the returned file does not have the Read Only check box checked and is not in a write-protected directory. |
NOTESTFILECREATE | Specifies that the file is not created before the dialog box is closed. |
NOVALIDATE | Specifies that the common dialog boxes allow invalid characters in the returned filename. |
OVERWRITEPROMPT | Causes the Save As dialog box to generate a message box if the selected file already exists. |
PATHMUSTEXIST | Specifies that the user can type only valid paths and filenames. |
READONLY | Causes the Read Only check box to be checked initially when the dialog box is created. |
SHAREAWARE | Specifies that if opening the selected file fails because of a network sharing violation, the error is ignored and the dialog box returns the selected filename. |
SHOWHELP | Causes the dialog box to display the Help button. |
Constructors
Name | Description |
---|---|
FileDialog() | Constructs a new FileDialog. |
Methods
Name | Description |
---|---|
getDefaultExt() | Returns the default file extension. |
getFilename() | Returns the filename selected in the file dialog. |
getFilenames() | Returns the list of filenames selected in the file dialog. |
getFilter() | Returns the current filter string. |
getFilterIndex() | Returns the index of the filter currently selected in the file dialog. |
getInitialDir() | Returns the initial directory set for the file dialog. |
getOptions() | Returns the option flags currently set for the file dialog. |
getTitle() | Returns the title set for the file dialog. |
hookProc(int hWnd, int msg, int wParam, int lParam) | Common dialog hook procedure. |
reset() | Resets all properties to their default values. |
runDialog(int hookProcPtr) | Implements running of a file dialog. |
setDefaultExt(String value) | Sets the default extension. |
setFilename(String value) | Sets the filename used to initialize the File Name edit control. |
setFilter(String value) | Sets the filters for the file dialog. |
setFilterIndex(int value) | Sets the current filter index. |
setInitialDir(String value) | Sets the initial file dialog directory. |
setOptions(int value) | Sets the option flags for the file dialog. |
setTitle(String value) | Sets the file dialog title. |
Constructs a new FileDialog.
Returns the default file extension.
Returns the filename selected in the file dialog. If multiple files are selected, the return value is the first filename in the list. If no file is selected, the return value is an empty string.
Returns the list of filenames selected in the file dialog. If no files are selected, the return value is an empty array.
Returns the current filter string.
Returns the index of the filter currently selected in the file dialog.
Returns the initial directory set for the file dialog.
Returns the option flags currently set for the file dialog. The READONLY and EXTENSIONDIFFERENT flags are updated by the file dialog when the user clicks OK.
Returns the title set for the file dialog.
Common dialog hook procedure. Centers the dialog on the screen in response to a CDN_INITDONE notification.
Resets all properties to their default values.
Implements running of a file dialog.
Sets the default extension. The file dialog append this extension to the filename if the user fails to type an extension. This string can be any length, but only the first three characters are appended. The string should not contain a period. The default value for the default extension is an empty string, which causes no extension to be appended.
Sets the filename used to initialize the File Name edit control.
Sets the filters for the file dialog. The filter string must consist of a number of filter pairs, separated by "|" characters. The first string in each pair is a display string that describes the filter (for example, "Text files"), and the second string specifies the filter pattern (for example, "*.txt"). To specify multiple filter patterns for a single display string, use a semicolon to separate the patterns (for example, "*.txt;*.doc;*.bak"). A pattern string can be a combination of valid filename characters and the asterisk (*) wildcard character. Do not include spaces in the pattern string. The following is an example of a filter string:
"Java files (*.java)|*.java|All files (*.*)|*.*"
The file dialog does not change the order of the filters. It displays them in the File Types combo box in the order specified by setFilter().
Sets the current filter index. The first pair of filter strings has an index value of 1, the second pair 2, and so on. You can specify an index on input to indicate the initial filter description and filter pattern for the dialog box. When the file dialog returns, getFilterIndex() returns the index of the currently displayed filter.
Sets the initial file dialog directory. If the specified directory is an empty string, the system uses the current directory as the initial directory.
Sets the option flags for the file dialog. The default value for the option flags is 0.
Sets the file dialog title. The given string is placed in the title bar of the dialog box. If specified title is an empty string, the system uses the default title (that is, "Save As" or "Open").