4

For a WPF-application i'm programming using c#, i want to check if a specific USB device (in this case it's a Philips GoGear Vibe) is connected to the PC.

Basically I want a function that checks this and returns a bool.

I would also lik to be able to find the drive letter to which this USB device is connected.

I've googled this but none of the answers really satisfies what I need.

Soner Gönül
  • 97,193
  • 102
  • 206
  • 364
svdotbe
  • 168
  • 1
  • 3
  • 16
  • Please have a look here http://stackoverflow.com/questions/3331043/get-list-of-connected-usb-devices – Christos May 09 '14 at 13:51

1 Answers1

1

go look at these links.

USB Device Connected C# detect usb device ClassCode (usb device type) http://social.msdn.microsoft.com/Forums/en-US/e6f074b3-31ae-4d9d-9aee-6eda728b17f6/detecting-usb-device-insertion-in-c

That should help you with your check to see if the drive was connected. To see the drives letter and path, put an event on in the solution from the link i added and just use

DriveInfo[] allDrives = DriveInfo.GetDrives();

note that you need to do this as an initialisation for your drives, just compare the initialized drives and the new drives list on event and the odd one out will be your drive letter. there are other ways of doing this though, that one has many flaws in it.

Community
  • 1
  • 1
Jonny
  • 401
  • 2
  • 11
  • Also, i believe that if you read in the microsoft link, there is a solution that allows you to get the drive letter with its ID, which is a better method than mine. Good luck – Jonny May 09 '14 at 13:48