C# Program to Get Computer Drive Names of Given Directory Last Updated : 26 Jan, 2022 Comments Improve Suggest changes Like Article Like Report Directory class provides different types of methods for creating, moving, deleting, renaming, and modifying directories and subdirectories. GetLogicalDrives() is the method of the Directory class. This method is used to find the name of the logical drive names present in the computer. Or we can say that this method returns the drive names of the given directory. The returned string is represented like this "<drive name>:\". Syntax: string[] Directory.GetLogicalDrives(); Return: It will return the directory names with string type. Exception: This method will throw the following exception: IOException: This exception will occur when the I/O error appears.UnauthorizedAccessException: This exception will occur when the caller does not have the specified permissions.Approach: 1. Create a variable to initiate the drive data named "drives_data". 2. Now find the name of the drives present in the computer system using the GetLogicalDrives() method. 3. Now use the length function to get the length of drives for displaying inside for loop for(int i = 0; i < drives_data.Length; i++) { // Display drive names Console.WriteLine(drives_data[i]); }Example: C# // C# program to find the computer drive names // of given directory using System; using System.IO; class GFG{ static void Main() { string[] drives_data; // Getting the drives names // Using GetLogicalDrives() method drives_data = Directory.GetLogicalDrives(); Console.WriteLine("Computer Drives in my system:"); for(int i = 0; i < drives_data.Length; i++) { // Display drive names Console.WriteLine( drives_data[i]); } } } Output: Computer Drives in my system: C:/ D:/ E:/ Comment More infoAdvertise with us Next Article C# Program to Get the List of Sub-Directories of a Given Directory S sravankumar_171fa07058 Follow Improve Article Tags : C# C# Programs Similar Reads 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 t 2 min read C# Program to Get the List of Files From Given Directory Given a directory, now we will find the list of files from the given directory. So for this, we use the GetFiles() method of the Directory class. This method is used to find the list of files from the given directory or sub directories. The overloaded methods of this method are: 1. GetFiles(String): 2 min read C# Program to Get Complete Path of Current Directory Given a directory, now our task is to find the path of the given directory or current directory. So to this task, we use the GetCurrentDirectory() method of the Directory class. This method will return the complete path of the current directory. The result given by this method will not end with a ba 1 min read C# Program to Get the List of Sub-Directories of a Given Directory Given a director, now we will find the list of the sub-directories present in the given directory. So to this task, we use the GetDirectories() method of the Directory class. This method is used to get the list of directories/sub-directories from the given directory or sub-directories. We have to sp 2 min read C# Program to Search Sub-Directory in a Given Directory C# is a general-purpose,  object-oriented programming language pronounced as âC Sharpâ. It is a lot syntactically similar to Java and is easy for users who have knowledge of C, C++, or Java. In this article, we will learn How can we use C# to search the sub-Directory in a given Directory. So for  t 3 min read C# Program to Demonstrate the Use of CreateSubdirectory Method DirectoryInfo class provides different types of methods and properties that are used to perform operations on directories and sub-directories like creating, moving, etc. This class has a CreateSubdirectory() method that is used to create a sub-directory or sub-directories on the given path. Here the 2 min read Like