Exemple #1
0
 private static IEnumerable <UsbDevice> ListHub(UsbHub hub, string driveName)
 {
     foreach (var port in hub.GetPorts())
     {
         if (port.IsHub)
         {
             foreach (var device in UsbLogic.ListHub(port.GetHub(driveName), driveName))
             {
                 yield return(device);
             }
         }
         else
         {
             if (port.IsDeviceConnected)
             {
                 yield return(port.GetDevice(driveName));
             }
         }
     }
 }
Exemple #2
0
 public static IEnumerable <UsbDevice> GetConnectedDevices(string driveName)
 {
     foreach (var device in UsbHost.GetControllers().Select(x => x.GetRootHub()).SelectMany(x => UsbLogic.ListHub(x, driveName)))
     {
         yield return(device);
     }
 }