How can I cover all sections on a C # hard drive

How can I get to all partitions on the hard drive in C # without running the directory path. Since some people split the hard drive into 3, 4, maybe five, and I want my program to be completely crawler.

like this

List<string> dirs = FileHelper.GetFilesRecursive("c:\\..........");

I don’t want just C I want D, E, F ....... etc.

+3
source share
2 answers

you can use Environment.GetLogicalDrives () to get a list of all disks (both physical and logical partitions).

+5
source

You can use:

// Store the list of drives into an array of string
string[] DriveList = Environment.GetLogicalDrives();
// Loop through the array
for (int i = 0; i < DriveList.Length; i++)
{
    // Show each drive
    MessageBox.Show(DriveList[i]);
}
+4
source

Source: https://habr.com/ru/post/1792489/


All Articles