Share via


Path.GetPathRoot Method

Gets the root directory information of the specified path.

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

Syntax

public static string GetPathRoot (
         stringpath
)

Parameters

  • path
    The path from which to obtain root directory information.

Return Value

A string containing the root directory of path, such as "C:\", or a null reference if path is a null reference, or an empty string if path does not contain root directory information.

Remarks

The .NET Framework does not support direct access to physical disks through paths that are device names, such as "\\.\PHYSICALDRIVE0 ".

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).

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