FileDialog.SafeFileName Property

Definition

Important

Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.

Gets a string that only contains the file name for the selected file.

C#
public string SafeFileName { [System.Security.SecurityCritical] get; }
C#
public string SafeFileName { get; }

Property Value

A String that only contains the file name for the selected file. The default is Empty, which is also the value when either no file is selected or a directory is selected.

Attributes

Remarks

This value is the FileName with all path information removed. Removing the paths makes the value appropriate for use in partial trust applications, since it prevents applications from discovering information about the local file system.

If more than one file name is selected (length of SafeFileNames is greater than one) then this property contains only the first selected file name.

See Safe File Upload from an XBAP Sample.

Applies to

Product Versions
.NET Framework 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9, 10