i have used ManagementObjectSearcher class for listing the drives...
there is no error but it does not display the output....
please can anyone check the code and tell me whether this approach is right...If not please tell me what is wrong with this...and what modifications should i do to get required drives in the server?
private void button1_Click(object sender, EventArgs e)
{
try
{
ManagementObjectSearcher mosDisks = new ManagementObjectSearcher("SELECT name FROM Win32_DiskDrive");
// Loop through each object (disk) retrieved by WMI
foreach (ManagementObject moDisk in mosDisks.Get())
{
// Add the HDD to the list (use the Model field as the item's caption)
listBox1.Items.Add(moDisk["Model"].ToString());
}
}
catch (ManagementException me)
{
MessageBox.Show(me.ToString());
}
}

New Topic/Question
Reply




MultiQuote




|