using c# how can I extract information about the hard drives present on the local machine

AndyM picture AndyM · Oct 24, 2008 · Viewed 10.8k times · Source

I'm looking to get data such as Size/Capacity, Serial No, Model No, Heads Sectors, Manufacturer and possibly SMART data.

Answer

Eoin Campbell picture Eoin Campbell · Oct 24, 2008

You can use WMI Calls to access info about the hard disks.

//Requires using System.Management; & System.Management.dll Reference

ManagementObject disk = new ManagementObject("win32_logicaldisk.deviceid=\"c:\""); 
disk.Get(); 
Console.WriteLine("Logical Disk Size = " + disk["Size"] + " bytes"); 
Console.WriteLine("Logical Disk FreeSpace = " + disk["FreeSpace"] + "bytes");