Click here to Skip to main content
16,023,047 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
Hi all. I use code listed below to determine Drive Signature, but I don't know how to get DriveLetter.

using System.Management;

string Signature;
ManagementObjectSearcher searcher = new
ManagementObjectSearcher("SELECT * FROM Win32_DiskDrive");
foreach (ManagementObject wmi_HD in searcher.Get())
{

try
{
Signature = wmi_HD["Signature"].ToString();
}
catch (Exception)
{
Signature = "Unknown";
}

MessageBox.Show(Signature);//need to know current DriveLetter too
}

The final goal is to get a Signature of needed Drive.
Posted
Updated 11-Apr-10 11:16am
v2

1 solution

C#
private void btnGetDrive_Click(object sender, System.EventArgs e)
{
   // Store this in string array
   string[] drives = Environment.GetLogicalDrives();
   // Loop string 
   foreach(string strDrive in drives)
   {
      // Add items (drives) to the list
      listBox1.Items.Add(strDrive.ToString());
   }
}



This should give you the list of all drives on a system

Hope this helps
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900