Share via


GetPathRoot Method

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

Gets the root directory information of the specified path.

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

Syntax

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

Parameters

Return Value

Type: System. . :: . .String
The root directory of path, such as "C:\", or nullNothingnullptrunita null reference (Nothing in Visual Basic) if path is nullNothingnullptrunita null reference (Nothing in Visual Basic), or an empty string if path does not contain root directory information.

Remarks

This method does not verify that the path or file name exists.

Possible patterns for the string returned by this method are as follows:

  • An empty string (path specified a relative path on the current drive or volume).

  • "/" (path specified an absolute path on the current drive).

  • "X:" (path specified a relative path on a drive, where X represents a drive or volume letter).

  • "X:/" (path specified an absolute path on a given drive).

  • "\\ComputerName\SharedFolder" (a UNC path).

.NET Framework Security

See Also

Reference

Path Class

System.IO Namespace