Visual Basic Reference
Returns or sets the path and filename of a selected file. Not available at design time for the FileListBox control.
object.FileName [= pathname]
The FileName property syntax has these parts:
|Object||An object expression that evaluates to an object in the Applies To list.|
|Pathname||A string expression that specifies the path and filename.|
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 CommonDialog 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.
- Changing the value of this property may also cause one or more of these events: PathChange (if you change the path), PatternChange (if you change the pattern), or DblClick (if you assign an existing filename).
- This property setting can be a qualified network path and filename using the following syntax: