0

I want to fetch the details of Portable devices that how many portable devices are connected to my pc.

I have already used the below mentioned code but still can't get any solution.

 static List<USBDeviceInfo> GetUSBDevices()
    {
      List<USBDeviceInfo> devices = new List<USBDeviceInfo>();

      ManagementObjectCollection collection;
      using (var searcher = new ManagementObjectSearcher("Select * From Win32_USBHub"))
        collection = searcher.Get();      

      foreach (var device in collection)
      {
          devices.Add(new USBDeviceInfo(
          (string)device.GetPropertyValue("DeviceID"),
          (string)device.GetPropertyValue("PNPDeviceID"),
          (string)device.GetPropertyValue("Description")
          ));
      }

      collection.Dispose();
      return devices;


    }
  • Welcome to Stack Overflow. This is not a good way to ask a question here. Did you try _anything_ so far to solve your problem? Show your effort first so people might show theirs. Please read [FAQ], [ask] and [help] as a start.. – Soner Gönül May 02 '14 at 11:43
  • Hi, sorry for that, and yes i applied above code but yes using driverinfo i can find the drive details and also can find removable devices but can't get portable device details. so please help me. – user3555862 May 02 '14 at 11:47
  • Refer link which has the question same as yours. http://stackoverflow.com/questions/6162046/enumerating-windows-portable-devices-in-c-sharp – Ravi Patel May 02 '14 at 13:45
  • Hi Ravi, it's not working for my application. if i attached any mobile device through usb port den i want that device details like device name and all. if anyone know about it then please help me. – user3555862 May 05 '14 at 09:32

0 Answers0