Extensions Reference

Extensions Reference > exDialogs


dlgBrowseForFile

string dlgBrowseForFile(bool IsOpenDialog, string DefExt, string Filters);

 

Displays a file selection dialog

The DLGBROWSEFORFILE function displays a standard Windows file selection dialog for the user to select or supply a filename. This function can be used for file loading and saving. Only one file may be selected, to allow multiple selections use the dlgBrowseForMultiFile function.

 

Parameters

IsOpenDialog

TRUE if the dialog should be a "File Open" dialog, otherwise FALSE to display a "File Save" dialog.

DefExt

The default file extension to use when no file extension is supplied by the user. For example, using "doc" in this parameter when the user supplies a filename of "Mydoc" will provide an actual filename of "Mydoc.doc".

Filters

This parameter is used to determine the type of filename a file must have to be displayed in the file list box. The first string in the string pair describes the filter; the second string indicates the file extension to use. Multiple extensions may be specified using ';' as the delimiter. The string ends with two '|' characters. This is a sample filter that allows GIF, JPG and BMP images:

GIF images (*.gif)|*.gif|JPEG images (*.jpg)|*.jpg|Bitmap images (*.bmp)|*.bmp||

This is a sample filter that only allows .txt files:

Text files (*.txt)|*.txt||

 

Return Value

The path and name of the file selected, or an empty string if Cancel was clicked.

 

Example Code

// Prompt for a filename to save to
string File = dlgBrowseForFile(False, "ssn", "Shiny code (*.ssn)|*.ssn||");