Gets the file name and extension for the file selected in the dialog box. The file name does not include the path.
<BrowsableAttribute(False)> _ Public ReadOnly Property SafeFileName As String
Dim instance As OpenFileDialog Dim value As String value = instance.SafeFileName
[BrowsableAttribute(false)] public string SafeFileName { get; }
[BrowsableAttribute(false)] public: property String^ SafeFileName { String^ get (); }
public function get SafeFileName () : String
A safe file name (just the file name and extension without a path) can be used to improve security for applications because it does not expose path information. This property should be accessible to code running with limited trust.
Windows 7, Windows Vista, Windows XP SP2, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003
If you are using Framework 2.0 PRE SP1 - Use Path.GetFileName with the FileName property.
eg:
string SafeFileName = Path.GetFileName(ofd.FileName.ToString());