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 Files of type 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 "Setting Files (*.r2w)", and a DOS wildcard file filter specification corresponding to that type of file, such as "*.txt" or "*.r2w." You can specify a single file filtering criterion:

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

 Or, multiple file filtering criteria, also separated by commas:
"Text Files (*.txt),*.txt,Bitmaps (*.bmp),*.bmp"

If this argument is omitted, the default is "All Files (*.*),*.*".

FilterIndex Argument Type: Integer
Identifies the default FileFilter¾that is, what type of files are listed in the Files of type box when the dialog box is first opened. Use 1 to specify the first FileFilter, 2 to specify the second FileFilter, and so on.

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. If you are using this value to create a host file, remember to strip off the drive and path information. Also, you may want to check the case of the file name returned (uppercase or lowercase) and modify it as needed for a host file name.


image\jump.gif Example

image\jump.gif Keyword Index

image\popup.gif Related Topics

image\popup.gif Reflection products that use this command