list of physical disks

  • Thread starter Thread starter Alex K.
  • Start date Start date
A

Alex K.

Hi all

How do I get the list of all physical disks attached to my computer, similar
to what is displayed under Disk drives in Device Manager:

0: MAXTOR 6L040j2
1: ST3802110a

Thank you
 
Hi all

How do I get the list of all physical disks attached to my computer, similar
to what is displayed under Disk drives in Device Manager:

0: MAXTOR 6L040j2
1: ST3802110a

Thank you

You may want to consider:

DriveInfo[] colDrives = DriveInfo.GetDrives();
DriveInfo diDrive;

foreach (DriveInfo di in colDrives)
{
Console.WriteLine(di.Name);
Console.WriteLine(di.DriveType);
Console.WriteLine(di.DriveFormat);
Console.WriteLine(di.AvailableFreeSpace);
Console.WriteLine(di.VolumeLabel);
Console.WriteLine("");
}
Console.ReadKey();

Unfortunately, you cannot get the Drive Manufacturer and Model.
 
Joe,

GetDrives gives list of logical drives, not physical disks. E.g. if you have
5 partitions on a single disk GetDrives will give you 5 DriveInfo items. I
need a list of physical disks -- same as in Device Manager | Disk drives
subtree.

Thank you

Joe Cool said:
Hi all

How do I get the list of all physical disks attached to my computer, similar
to what is displayed under Disk drives in Device Manager:

0: MAXTOR 6L040j2
1: ST3802110a

Thank you

You may want to consider:

DriveInfo[] colDrives = DriveInfo.GetDrives();
DriveInfo diDrive;

foreach (DriveInfo di in colDrives)
{
Console.WriteLine(di.Name);
Console.WriteLine(di.DriveType);
Console.WriteLine(di.DriveFormat);
Console.WriteLine(di.AvailableFreeSpace);
Console.WriteLine(di.VolumeLabel);
Console.WriteLine("");
}
Console.ReadKey();

Unfortunately, you cannot get the Drive Manufacturer and Model.
 
Hi all,

you should use the Windows Management Interface (WMI). I know, it is only
a VB Page, but have a look here:
http://www.aspfree.com/c/a/Windows-...esFilesFolders-using-WMI-and-Visual-BasicNET/
http://msdn.microsoft.com/en-us/library/aa394132(VS.85).aspx

The available properties are quite numerous.

Cheers,
Steffen
Joe,

GetDrives gives list of logical drives, not physical disks. E.g. if
you have 5 partitions on a single disk GetDrives will give you 5
DriveInfo items. I need a list of physical disks -- same as in Device
Manager | Disk drives subtree.

Thank you

Joe Cool said:
Hi all

How do I get the list of all physical disks attached to my computer,
similar to what is displayed under Disk drives in Device Manager:

0: MAXTOR 6L040j2
1: ST3802110a
Thank you
You may want to consider:

DriveInfo[] colDrives = DriveInfo.GetDrives();
DriveInfo diDrive;
foreach (DriveInfo di in colDrives)
{
Console.WriteLine(di.Name);
Console.WriteLine(di.DriveType);
Console.WriteLine(di.DriveFormat);
Console.WriteLine(di.AvailableFreeSpace);
Console.WriteLine(di.VolumeLabel);
Console.WriteLine("");
}
Console.ReadKey();
Unfortunately, you cannot get the Drive Manufacturer and Model.
 
Alex said:
GetDrives gives list of logical drives, not physical disks. E.g. if you have
5 partitions on a single disk GetDrives will give you 5 DriveInfo items. I
need a list of physical disks -- same as in Device Manager | Disk drives
subtree.

Try and see what this prints:

WqlObjectQuery q = new WqlObjectQuery("SELECT * FROM
Win32_DiskDrive");
ManagementObjectSearcher res = new ManagementObjectSearcher(q);
foreach (ManagementObject o in res.Get()) {
Console.WriteLine("Caption = " + o["Caption"]);
Console.WriteLine("DeviceID = " + o["DeviceID"]);
Console.WriteLine("Decsription = " + o["Description"]);
Console.WriteLine("Manufacturer = " + o["Manufacturer"]);
Console.WriteLine("MediaType = " + o["MediaType"]);
Console.WriteLine("Model = " + o["Model"]);
Console.WriteLine("Name = " + o["Name"]);
// only Vista & 2008: //Console.WriteLine("SerialNumber = "
+ o["SerialNumber"]);
}

Arne
 
Back
Top