• <GetStart>
  • CSPro User's Guide
    • The CSPro System
    • Data Dictionary Module
    • The CSPro Language
    • Data Entry Module
    • Batch Editing Applications
    • Tabulation Applications
    • Data Sources
    • CSPro Statements and Functions
    • Templated Reporting System
    • HTML and JavaScript Integration
    • Action Invoker
      • Overview
      • Execution Environments
      • Security and Formatting Options
      • Base Actions
      • Application Namespace
      • Clipboard Namespace
      • Data Namespace
      • Dictionary Namespace
      • File Namespace
      • Hash Namespace
      • Localhost Namespace
      • Logic Namespace
      • Message Namespace
      • Path Namespace
        • Path Action Invoker Namespace
        • Path.createDirectory Action
        • Path.getDirectoryListing Action
        • Path.getPathInfo Action
        • Path.getSpecialPaths Action
        • Path.selectFile Action
        • Path.showFileDialog Action
      • Settings Namespace
      • Sqlite Namespace
      • System Namespace
      • UI Namespace
    • Appendix
  • <CSEntry>
  • <CSBatch>
  • <CSTab>
  • <DataViewer>
  • <TextView>
  • <TblView>
  • <CSFreq>
  • <CSDeploy>
  • <CSPack>
  • <CSDiff>
  • <CSConcat>
  • <Excel2CSPro>
  • <CSExport>
  • <CSIndex>
  • <CSReFmt>
  • <CSSort>
  • <ParadataConcat>
  • <ParadataViewer>
  • <CSCode>
  • <CSDocument>
  • <CSView>
  • <CSWeb>

Path.showFileDialog Action

Format
s = CS.Path.showFileDialog(ʃtype := ...ʅ
                         
ʃ, title := ...ʅ
                         
ʃ, filter := ...ʅ
                         
ʃ, startDirectory := ...ʅ
                         
ʃ, rootDirectory := ...ʅ
                         
ʃ, showDirectories := ...ʅ
                         
ʃ, name := ...ʅ
                         
ʃ, confirmOverwrite := ...ʅ
                         
ʃ, useNativeDialog := ...ʅ)
ArgumentDescriptionTypes / Required
typeThe dialog type: "open" for opening files or "save" for saving files.
The default value is "open".
string
not required
titleThe title of the dialog.string
not required
filterA wildcard used to filter the files.string
not required
startDirectoryThe path of the directory to be initially shown to the operator.string
not required
rootDirectoryThe path of the directory above which the operator cannot navigate.string
not required
showDirectoriesIf 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
nameThe initial filename, or a suggested filename.string
not required
confirmOverwriteIf true, a confirmation message will appear when trying to overwrite an existing file.
The default value is true.
boolean
not required
useNativeDialogIf 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
Description
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.
Return Value
The action returns a string containing the fully evaluated path of the selected file, or undefined if no file was selected.
Exceptions
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.
Example (JavaScript): Open File Dialog
const pdfPath = CS.Path.showFileDialog({
    title: 
"Select a PDF",
    filter: 
"*.pdf"
});

if( pdfPath !== undefined ) {
   
// ...
}
Example (JavaScript): Save File Dialog
const imagePath = CS.Path.showFileDialog({
    type: 
"save",
    title: 
"Save Roof Image As",
    filter: 
"*.jpg",
    rootDirectory: 
"household-images",
    name: 
"roof.jpg"
});

if( imagePath !== undefined ) {
   
// ...
}
See also: Path Action Invoker Namespace, Path.selectFile Action