Click or drag to resize
PathGetFileName Method
Returns the file name and extension of the specified path string.

Namespace: System.IO
Assembly: mscorlib (in mscorlib.dll) Version: 4.0.0.0
Syntax
C#
public static string GetFileName(
	string path
)

Parameters

path
Type: SystemString
The path string from which to obtain the file name and extension.

Return Value

Type: String
The characters after the last directory character in path. If the last character of path is a directory or volume separator character, this method returns Empty. If path is null, this method returns null.
Exceptions
ExceptionCondition
ArgumentExceptionpath contains one or more of the invalid characters defined in GetInvalidPathChars.
See Also