s = CS.Path.showFileDialog(ʃtype := ...ʅ
ʃ, title := ...ʅ
ʃ, filter := ...ʅ
ʃ, startDirectory := ...ʅ
ʃ, rootDirectory := ...ʅ
ʃ, showDirectories := ...ʅ
ʃ, name := ...ʅ
ʃ, confirmOverwrite := ...ʅ
ʃ, useNativeDialog := ...ʅ)
Argument | Description | Types / Required |
type | The dialog type: "open" for opening files or "save" for saving files.
The default value is "open". | string
not required |
title | The title of the dialog. | string
not required |
filter | A wildcard used to filter the files. | string
not required |
startDirectory | The path of the directory to be initially shown to the operator. | string
not required |
rootDirectory | The path of the directory above which the operator cannot navigate. | string
not required |
showDirectories | If false, the operator will not see subdirectories and will not be able to navigate to a parent directory.
The default value is true. | boolean
not required |
name | The initial filename, or a suggested filename. | string
not required |
confirmOverwrite | If true, a confirmation message will appear when trying to overwrite an existing file.
The default value is true. | boolean
not required |
useNativeDialog | If true, on Windows, instead of displaying an HTML dialog, the native Windows open/save file dialogs will display.
The default value is false. | boolean
not required |
The
Path.showFileDialog action displays a dialog with a visual listing of the file system, allowing the user to select a file to open or to create a file to save. Hidden and system files are not shown to the operator.
You can specify a wildcard
filter that filters the files shown in the visual listing. For example,
"*.csdb" would include only the paths of
CSPro DB data sources. You can specify multiple wildcard filters by separating each filter with a semicolon. The filter
"*.jpg;*.jpeg;*.bmp" would include both JPEG and BMP files. In addition to standard wildcard filters, you can use a predefined wildcard expression, specified with the
"|" prefix:
- "|FileType.Audio": Files that the Audio object can read and write.
- "|FileType.Geometry": Files that the Geometry object can read and write.
- "|FileType.Image": Files that the Image object can read and write.
Provide startDirectory to specify the initial directory shown to the operator and rootDirectory to control how much of the file system the operator can browse. Specifying a root directory prevents the operator from moving to a location above the root directory. If neither are provided, the operator will initially see files starting in the directory where the currently running application is located, and will have access to other files on that drive. If a root directory is provided without a start directory, the start directory will be set to the root directory. If both a start and root directory are provided, the root directory must be equal to or above the start directory. Generally both directory paths are directories, but they can also be one of the following special values, specified with the "|" prefix:
- The Android root directory, specified as "|Android".
- An Android Media Store directory, specified as one of the following: "|Media.Audio", "|Media.Images", or "|Media.Video". Note that files in these "directories" can actually reside in multiple directories.
By default, both files and directories are shown to the operator. To hide directories, set
showDirectories to
false.
If specifiying useNativeDialog to use the native Windows open/save file dialogs, the rootDirectory and showDirectories arguments are ignored and the operator will have access to the entire file system.
The action returns a string containing the fully evaluated path of the selected file, or undefined if no file was selected.
The action throws an exception if any of its arguments are not specified in a valid form or if either the start or root directories do not exist.
const pdfPath = CS.Path.showFileDialog({
title: "Select a PDF",
filter: "*.pdf"
});
if( pdfPath !== undefined ) {
// ...
}
const imagePath = CS.Path.showFileDialog({
type: "save",
title: "Save Roof Image As",
filter: "*.jpg",
rootDirectory: "household-images",
name: "roof.jpg"
});
if( imagePath !== undefined ) {
// ...
}