如何检测从C#应用程序中的USB驱动器盘符? [英] How do I detect a USB drive letter from a c# application?

查看:292
本文介绍了如何检测从C#应用程序中的USB驱动器盘符?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何检测从C#程序未居住在USB优盘的盘符?该计划应驻留在系统中,如果多个USB的连接,然后我首先应该能够得到制造商的名称也。

How to detect the USB drive letter from c# program which is not residing in the USB? The program should reside in the system, if multiple USB's are connected then i should first able to get the manufacturer name also.

推荐答案

这将让所有连接的可移动驱动器(包括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://stackoverflow.com/questions/123986/how-to-determine-usb-flash-drive-manufacturer
  • http://stackoverflow.com/questions/777569/finding-serial-number-of-usb-drive-without-wmi

这篇关于如何检测从C#应用程序中的USB驱动器盘符?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆