Get List of connected USB Devices using C# Console Application

Create new console application

To Get List of connected USB Devices:

The first step is to create a new console application.

Create new console application
Create a new console application
Add a reference to System.Management for your project.
add reference
add reference

Paste the following coding.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Management;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication1
    class Program
        static void Main(string[] args)
            var usbDevices = GetUSBDevices();

            foreach (var usbDevice in usbDevices)
                Console.WriteLine("Device ID: {0}, PNP Device ID: {1}, Description: {2}",
                    usbDevice.DeviceID, usbDevice.PnpDeviceID, usbDevice.Description);

        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(

            return devices;
    class USBDeviceInfo
        public USBDeviceInfo(string deviceID, string pnpDeviceID, string description)
            this.DeviceID = deviceID;
            this.PnpDeviceID = pnpDeviceID;
            this.Description = description;
        public string DeviceID { get; private set; }
        public string PnpDeviceID { get; private set; }
        public string Description { get; private set; }


Run the Application.

List of available USB device connected with the system
List of available USB device connected with the system

How useful was this post?

Click on a star to rate it!

Average rating 3.9 / 5. Vote count: 9

No votes so far! Be the first to rate this post.

As you found this post useful...

Share this post on social media!

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?