C# Program to Get Root Directory of Given Directory
Directory class provides different types of methods for creating, moving, deleting, renaming, and modifying directories and subdirectories. GetDirectoryRoot() is a method of Directory class. This method is used to find the information of the volume or root or both for the given path. Or we can say that this method is used to find the root directory of the given directory.
public static string GetDirectoryRoot (string path);
Here, the path is the location of the directory or file.
Return: This method will return a string that will contain the information of the root or volume of the given path.
Exceptions: This method will throw the following exceptions:
- UnauthorizedAccessException: This exception will occur when the caller does not have the specified permission.
- ArgumentException: This exception will occur when the path is a zero-length string, or can contain only white space, or can contain one or more invalid characters.
- ArgumentNullException: This exception will occur when the path is null.
- PathTooLongException: This exception will occur when the specified path, file name, or both exceed the system-defined maximum length.
D C F
My Personal Notes arrow_drop_up
Please Login to comment...