Returns or sets the path and filename of a selected file.
Object.FileName [ = sFileName ]
The FileName property syntax has the following parts:
Name |
Type |
Description |
Object |
ACommonDialog |
ACommonDialog control |
sFileName |
BString |
The path and filename of a selected file. |
When you create the control at run time, the FileName property is set to a zero-length string (""), meaning no file is currently selected.
In the ACommonDialog control, you can set the FileName property before opening a dialog box to set an initial filename.
Reading this property returns the currently selected filename from the list. The path is retrieved separately, using the Path property. The value is functionally equivalent to List(ListIndex). If no file is selected, FileName returns a zero-length string.
When setting this property:
Including a drive, path, or pattern in the string changes the settings of the Drive, Path, and Pattern properties accordingly.
Including the name of an existing file (without wildcard characters) in the string selects the file.
This property setting can be a qualified network path and filename using the following syntax:
\\servername\sharename\pathname
If the file and its path are c:\mydir\myfile.txt, the following example will set the filename:
cdlg1.FileName=c:\mydir\myfile.txt
The following example will retrieve filename:
sfilename=cdlg1.FileName
FileTitle, InitialDir, OpenOptions, SaveAsOptions, ShowSaveAs