Programming with Reflection

image\rwnprg32.gif GetOpenFileName method


Syntax FileName = object.GetOpenFileName([FileFilter] [, FilterIndex], [,Title], [,ButtonText])



Opens a standard Windows dialog box for opening a file and gets the name of an existing file from the user (without actually opening any files).


FileFilter Argument type: String
Specifies one or more file filtering criteria. These are used to fill a List files of type list box in the dialog box, and allow the user to select from different types of files to open.

 A file filtering criterion has two parts, separated by a comma: A description, such as "Text Files (*.txt)" or "Settings Files (*.rsf)", and a DOS wildcard file filter specification corresponding to that type of file, such as "*.txt" or "*.rsf". You can specify a single file filtering criterion as shown in these two examples:

 "Text Files (*.txt),*.txt"

 "All Files (*.*),*.*"

 Or multiple file filtering criteria, also separated by commas:

 "Text Files (*.txt),*.txt,Bitmaps (*.bmo),*.bmp"

 If this argument is omitted, all files are listed.

FilterIndex Argument type: String
Identifies the default FileFilter—that is, what type of files are listed in the File Type list box when the dialog box first opens. Use 1 to specify the first FileFilter, 2 to specify the second FileFilter, and so on. If you omit this argument, the dialog box will default to the first FileFilter.

Title Argument type: String
Specifies a title for the dialog box. If this argument is omitted, the title is "Open".

ButtonText Argument type: String
Specifies the text for the default button in the dialog box. If this argument is omitted, the button text is "Open".


FileName Return type: String
The file name (including drive and path information) the user selects, or an empty string if the user selects Cancel.


image\jump.gif Example

image\jump.gif Keyword Index

image\popup.gif Related Topics

image\popup.gif Reflection products that use this command