FileSystem.GetName Method (String)


The .NET API Reference documentation has a new home. Visit the .NET API Browser on to see the new experience.

Parses the file name out of the path provided.

Namespace:   Microsoft.VisualBasic.FileIO
Assembly:  Microsoft.VisualBasic (in Microsoft.VisualBasic.dll)

public static string GetName(
	string path


Type: System.String

Required. Path to be parsed. String.

Return Value

Type: System.String

The file name from the specified path.

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.



Parse a file path

How to: Parse File Paths in Visual Basic

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

MsgBox("The filename is: " &

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

.NET Framework
Available since 2.0
Return to top