FileName Property (ACommonDialog)

Returns or sets the path and filename of a selected file.

Syntax

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.

Comments

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:

This property setting can be a qualified network path and filename using the following syntax:

\\servername\sharename\pathname

Example

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

Applies to

ACommonDialog

See Also

FileTitle, InitialDir, OpenOptions, SaveAsOptions, ShowSaveAs