In This Topic
Gets only the file name and the extension of the given path. Also works for directories. For example, if the path is "C:\Documents\MyFile.txt", this method returns "MyFile.txt". If the path it "C:\Documents", this method returns "Documents".
Syntax
public System.string GetFileName(
System.string
)
Parameters
- path
Return Value
The characters after the last directory separator character in path. If the last character of path is a directory or volume separator character, this method returns String.Empty. If path is null, this method returns null.
Requirements
Target Platforms: Windows 11, Windows 10, Windows 7, Windows Server 2019, Windows Server 2016, Windows Server 2012 R2, Windows Server 2012, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later)
See Also