且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何检测从C#应用程序中的USB驱动器盘符?

更新时间:2021-06-29 02:06:46

这将让所有连接的可移动驱动器(包括USB驱动器)的:

This will get all of the removable drives attached (including USB drives):

foreach (DriveInfo drive in DriveInfo.GetDrives())
{
    if (drive.DriveType == DriveType.Removable)
    {
        // Code here
    }
}

获取USB驱动器制造商可能会更加困难,你可能需要使用WMI。

Getting the USB drive manufacturer may be more difficult, and you may need to use WMI.

修改:下面是关于阅读的USB驱动器的信息2链接:

Edit: Here are 2 links on reading USB drive information:

  • http://***.com/questions/123986/how-to-determine-usb-flash-drive-manufacturer
  • http://***.com/questions/777569/finding-serial-number-of-usb-drive-without-wmi