Ads Inside Post

Search in This Blog

Get Volume Serial Number of Drive in C#

Listed below the code use in your project to get Volume serial number

//let's show C drive's volume serial number
String d = "c";
try {
    System.Management.ManagementObject dsk1 = new System.Management.ManagementObject(@"win32_logicaldisk.deviceid=""" + d + @":""");
    dsk1.Get();
    string s1 = dsk1["VolumeSerialNumber"].ToString();
    MessageBox.Show(s1);
}
catch (Exception ee)
{
    MessageBox.Show(ee.ToString());

}