radi soufan
radi soufan

Reputation: 31

How I can Reach all partitions in the hard drive in c#

How can I reach all partitions in the hard drive in c# just without writing the directory path. Because some people part the harddisk to 3, 4 maybe five and I want my program completely searcher.

like this

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

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

Upvotes: 3

Views: 960

Answers (2)

Jaime Oro
Jaime Oro

Reputation: 10135

You could 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]);
}

Upvotes: 4

Paolo Falabella
Paolo Falabella

Reputation: 25844

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

Upvotes: 5

Related Questions