The FileDialog class

The FileDialog class
This class provides dialogs that allow users to select files or directories. The following function call will open a file dialog with that will display files with the extension .txt.
var filename = FileDialog.getOpenFileName( "*.txt" );
if (filename) {
    processfile(filename);
}
  • getOpenFileName( filter : String, title : String ); Opens an "Open" dialog. If filter is specified (e.g. "textfiles (*.txt)"), only those files which match the filter are shown. The function returns a string with the selected filename, or undefined if the user canceled.

  • getSaveFileName( filter : String, title : String ); Opens an "Save As" dialog. If filter is specified (e.g. "textfiles (*.txt)"), only those files which match the filter are shown. The function returns a string with the filename selected or entered, or undefined if the user canceled.

  • getExistingDirectory( dir : String, title : String ); Opens a "Find Directory" dialog for the user to select an existing directory. The parameter dir can be used to specify the initial directory. Returns the name of the selected directory or undefined if the user canceled.

  • getOpenFileNames( dir : String, filter : String, title : String ); Opens an "Open" dialog for the user to select and open one or more existing files. If dir is specified it specifies the initial directory. If filter is specified (e.g. "textfiles (*.txt)"), only those files which match the filter are shown. The function returns a list of string string with the selected filenames, or undefined if the user canceled.