How to detect the USB drive letter from c# program which is not residing in the USB? The program should reside in the system, if multiple USB's are connected then i should first able to get the manufacturer name also.
+3
A:
This will get all of the removable drives attached (including USB drives):
foreach (DriveInfo drive in DriveInfo.GetDrives())
{
if (drive.DriveType == DriveType.Removable)
{
// Code here
}
}
Getting the USB drive manufacturer may be more difficult, and you may need to use WMI.
Edit: Here are 2 links on reading USB drive information:
Jon Tackabury
2009-08-13 18:52:49
A:
Thanks Jon. But please give me some hint on WMI.
Suppose i can handle this way:
- Pass a particular manufacturer name as a paramater and get the drive letter for which this manufacturer name matches.
Please assist.
Thanks in advance.
I've revised my answer to include 2 useful links.
Jon Tackabury
2009-08-13 19:03:10
Thanks a million Jon, it really worked and thanks again.
2009-08-13 19:12:32
No problem - glad it worked, and welcome to Stack Overflow. :) If my answer was helpful, please be sure to flag it as the accepted answer. Thanks!
Jon Tackabury
2009-08-13 19:22:21