Get List of connected USB Devices

前端 未结 8 1737
再見小時候
再見小時候 2020-11-22 08:27

How can I get a list of all the connected USB devices on a windows computer?

8条回答
  •  臣服心动
    2020-11-22 09:01

    This is a much simpler example for people only looking for removable usb drives.

    using System.IO;

    foreach (DriveInfo drive in DriveInfo.GetDrives())
    {
        if (drive.DriveType == DriveType.Removable)
        {
            Console.WriteLine(string.Format("({0}) {1}", drive.Name.Replace("\\",""), drive.VolumeLabel));
        }
    }
    

提交回复
热议问题