views:

299

answers:

3

I am writing a .net winforms application. I want to be able to do the following...

Enumerate all of the hard drives on a system.

Furthermore I would love to be able to determine which of the drives is Fixed and Which is removable.

Finally, of the removable drives, I would love to be able to determine which of them is a flash (SSD or thumb) drive versus a standard hard drive.

Any thoughts.

Seth

+5  A: 

For the first two points you want the following. I think you might have to switch to WMI to determine if a removable drive is solid state or hard drive based.

foreach(DriveInfo info in DriveInfo.GetDrives())
{
   Console.WriteLine(info.Name + ":" + info.DriveType);
}

Produces a list of all the drives and their type from the DriveType Enum

Ian
A: 

You can use WMI to do that. You'll need either Win32_DiskDrive or Win32_LogicalDisk.

Anton Gogolev
+1  A: 
DriveInfo[] drives = DriveInfo.GetDrives();
foreach (DriveInfo drive in drives)
{
    if (drive.DriveType == DriveType.Fixed)
    {
        // Do something
    }
    else if (drive.DriveType == DriveType.Removable)
    {
        // Do something else
    }
}

But I don't know how you can determine whether it's Flash, SSD or hard drive... maybe with WMI

Thomas Levesque