Click here to Skip to main content
15,886,873 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello,

I am trying to map the volume letter to USB device Id. For example, there is a USB hub connecting several USB devices. I can get the list of the logical drives, say "C", "D", ......, but not the mounted USB volumes. And I also can get the details of the devices that are connected to the hub. My question is that how I can map which volume letter to which device.

Thanks in Advance.

Yu

What I have tried:

Calling System.IO.Directory.GetLogicalDrives(); to get the logical drivers, but not the mounted USB volumes.
Posted
Updated 1-Feb-17 18:21pm
Comments
yucaroldeng 2-Feb-17 1:42am    
Thanks Suvendu! This works for showing the USB driver's name. Another question is that if there are more than one USB devices connected to the computer, how can I know which volume corresponds to which device? I am thinking to get device ID from the driver, am I on the right track? Thanks in advance.

1 solution

You try filtering USB drives from all the devices such as-(example using c#)
C#
List<string> usbDrives = new List<string>()
foreach (DriveInfo drive in DriveInfo.GetDrives())
{
    if (drive.DriveType == DriveType.Removable)
    {
        usbDrives.Add(drive.VolumeLabel);
    }
}


Not sure if it will able to find the USB drives connected at the hub.
Please try once and let me know if it doesn't work.

Thanks :)
 
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