[C#] How to Get all drives in C#

Hello friends !

Today I will show you how to use GetLogicalDrives method of returns all logical drives on a system. To do this, create a new Project and write the following code. The following example shows how to display the logical drives of the current computer using the GetLogicalDrives method.

string[] drives = System.IO.Directory.GetLogicalDrives();
foreach (string drive in drives)
{
    System.Console.WriteLine(drive);
}

I wish you success, please leave a comment below, we will answer all your questions.

GoodLuck !!!

 

 

 

 

Xem thêm  [C#] How to working with Directories in C#

Leave a Reply

Your email address will not be published. Required fields are marked *