Я пробовал использовать два кода, но ничего не получилось
Код: Выделить всё
StringCollection propNames = new StringCollection();
ManagementClass driveClass = new ManagementClass("Win32_DiskDrive");
PropertyDataCollection props = driveClass.Properties;
foreach (PropertyData driveProperty in props)
{
propNames.Add(driveProperty.Name);
}
int idx = 0;
ManagementObjectCollection drives = driveClass.GetInstances();
foreach (ManagementObject drv in drives)
{
Label2.Text+=(idx + 1);
foreach (string strProp in propNames)
{
//Label2.Text+=drv[strProp];
Response.Write(strProp + " = " + drv[strProp] + "");
}
}
А второй —
Код: Выделить всё
string drive = "C";
ManagementObject disk = new ManagementObject("win32_logicaldisk.deviceid=\"" + drive + ":\"");
disk.Get();
Label3.Text = "VolumeSerialNumber="+ disk["VolumeSerialNumber"].ToString();
Подробнее здесь: https://stackoverflow.com/questions/408 ... ial-number