Export (0) Print
Expand All

FileDialog.FileName Property

Gets or sets a string containing the file name selected in the file dialog box.

Namespace:  System.Windows.Forms
Assembly:  System.Windows.Forms (in System.Windows.Forms.dll)

member FileName : string with get, set

Property Value

Type: System.String
The file name selected in the file dialog box. The default value is an empty string ("").

The file name includes both the file path and the extension. If no files are selected, this method returns an empty string ("").

When used from the SaveFileDialog class, this property represents the file being saved; when used from the OpenFileDialog class, it represents the file being opened.

This property can only be the name of one selected file. If you want to return an array containing the names of all selected files in a multiple-selection dialog box, use FileNames.

The following code example demonstrates using the RichTextBox.SaveFile and RichTextBox.LoadFile methods with streams. It also demonstrates using the FileName, DefaultExt, SaveFileDialog.CreatePrompt, and SaveFileDialog.OverwritePrompt members.

This is a complete example that is ready to run when you copy it to your project.

No code example is currently available or this language may not be supported.
The following code example demonstrates using the 
RichTextBox.SaveFile and RichTextBox.LoadFile methods with streams.
It also demonstrates using the FileDialog.FileName, 
SaveFileDialog.CreatePrompt, SaveFileDialog.OverwritePrompt, and 
TextBox.Click members. This is a complete example that is ready to run when you copy it to your project.

.NET Framework

Supported in: 4.5.2, 4.5.1, 4.5, 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Show:
© 2014 Microsoft