Share via


Path.GetFileName Method

Returns the file name and extension of the specified path string.

Namespace: System.IO
Assembly: mscorlib (in mscorlib.dll)

Syntax

public static string GetFileName (
         stringpath
)

Parameters

  • path
    The path string from which to obtain the file name and extension.

Return Value

A String consisting of 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 a null reference, this method returns a null reference.

Remarks

The returned value is a null reference if the file path is a null reference.

The separator characters used to determine the start of the file name are DirectorySeparatorChar and AltDirectorySeparatorChar.

Version Information

Available in the .NET Micro Framework versions 3.0, 4.0, and 4.1.

See Also

Reference

Path Class
Path Members
System.IO Namespace