如何获取所有USB驱动器(已插入)[重复]

时间:2020-12-09 23:37:25

Possible Duplicate:
Get List Of USB Devices

可能重复:获取USB设备列表

Im making a WPF app.

我正在制作一个WPF应用程序。

Im looking for a way to list all plugged in USB devices (disks!) in my comboBox.

我正在寻找一种方法来列出我的comboBox中所有插入的USB设备(磁盘!)。

I can list all drives using DriveInfo.GetDrives(), but is there a simple way to filter that to USB devices?

我可以使用DriveInfo.GetDrives()列出所有驱动器,但是有一种简单的方法可以将其过滤到USB设备吗?

thanx

感谢名单

2 个解决方案

#1


13  

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

#2


0  

http://social.msdn.microsoft.com/Forums/en-US/csharpgeneral/thread/9f9eb8f5-297f-4acd-a9af-aafbe384fd71/

http://social.msdn.microsoft.com/Forums/en-US/csharpgeneral/thread/9f9eb8f5-297f-4acd-a9af-aafbe384fd71/

The accepted answer at that link seems to do what you're asking.

在那个链接上接受的答案似乎就是你所要求的。

#1


13  

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

#2


0  

http://social.msdn.microsoft.com/Forums/en-US/csharpgeneral/thread/9f9eb8f5-297f-4acd-a9af-aafbe384fd71/

http://social.msdn.microsoft.com/Forums/en-US/csharpgeneral/thread/9f9eb8f5-297f-4acd-a9af-aafbe384fd71/

The accepted answer at that link seems to do what you're asking.

在那个链接上接受的答案似乎就是你所要求的。