Redigera

Dela via


FileSystem.GetName(String) Method

Definition

Parses the file name out of the path provided.

public:
 static System::String ^ GetName(System::String ^ path);
public static string GetName (string path);
static member GetName : string -> string
Public Shared Function GetName (path As String) As String

Parameters

path
String

Required. Path to be parsed. String.

Returns

The file name from the specified path.

Examples

The following example parses a file path and returns the name of the file.

MsgBox("The filename is: " &
My.Computer.FileSystem.GetName("C:\testdirectory\testfile"))

Replace the path C:\Testdirectory\Testfile with the path you wish to parse.

Remarks

This is a string operation; the FileSystem is not examined.

The GetName method ignores a slash mark occurring at the end of the path.

The following table lists an example of a task involving the My.Computer.FileSystem.GetFileName method.

To See
Parse a file path How to: Parse File Paths in Visual Basic

Applies to