tags:

views:

670

answers:

2

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
A: 

Thanks Jon. But please give me some hint on WMI.

Suppose i can handle this way:

  1. 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
Thanks a million Jon, it really worked and thanks again.
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