Q:

C# Detect if usb device is inserted

I'd like to now if it is possible to only allow a C# application run if a usb device is inserted?
 The usb device is a Pololu micro servo controler. At the moment I'm cheking if it is connected throug the serial conection if the Pololu is sending a "Char" as I programed It. But some times the Pololu is connected but in a part of the loop where the Char is not sent, so in this case the application won't open even with the pololu connected. Is there a more reliable way to detect it?

A:

You can get the removable drives through the following code.
 using System.IO.DriveInfo;

 var availableDrives = DriveInfo.GetDrives()
.Where(d=> d.IsReady && d.DriveType == DriveType.Removable);

details of DriveInfo
You can also take a quick look at open source project LibUsbDotNet

