Share via


GetFileName Method

[This documentation is for preview only, and is subject to change in later releases. Blank topics are included as placeholders.]

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

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

Syntax

'Declaration
Public Shared Function GetFileName ( _
    path As String _
) As String
public static string GetFileName(
    string path
)
public:
static String^ GetFileName(
    String^ path
)
static member GetFileName : 
        path:string -> string 
public static function GetFileName(
    path : String
) : String

Parameters

Return Value

Type: System. . :: . .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 String..::..Empty. If path is nullNothingnullptrunita null reference (Nothing in Visual Basic), this method returns nullNothingnullptrunita null reference (Nothing in Visual Basic).

Remarks

The returned value is null Nothing nullptr unit a null reference (Nothing in Visual Basic) if the file path is null Nothing nullptr unit a null reference (Nothing in Visual Basic) .

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

.NET Framework Security

See Also

Reference

Path Class

System.IO Namespace