Hey,
I want to retrieve the list of fixed disks in a system. But C#s GetDrives Fixed Drives are including plug USB Harddisks.
Any idea how I may detect that a fixed Drive is not an USB harddisk or vica versa?
Ciao Ephraim
Hey,
I want to retrieve the list of fixed disks in a system. But C#s GetDrives Fixed Drives are including plug USB Harddisks.
Any idea how I may detect that a fixed Drive is not an USB harddisk or vica versa?
Ciao Ephraim
use DriveType to detect the type of the drive:
using System.IO;
DriveInfo[] allDrives = DriveInfo.GetDrives();
foreach (DriveInfo d in allDrives)
{
if (d.IsReady && d.DriveType == DriveType.Fixed)
{
// This is the drive you want...
}
}
EDIT1:
check the following link: How do I detected whether a hard drive is connected via USB?
Solution nicked from http://stackoverflow.com/questions/450009/how-to-get-serial-number-of-usb-stick-in-c :
//import the System.Management namespace at the top in your "using" statement.
ManagementObjectSearch theSearcher = new ManagementObjectSearcher(
"SELECT * FROM Win32_DiskDrive WHERE InterfaceType='USB'");