如何发现USB存储设备和可写CD/DVD驱动器(C#) [英] How to discover USB storage devices and writable CD/DVD drives (C#)
本文介绍了如何发现USB存储设备和可写CD/DVD驱动器(C#)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何查找给定时间(使用C#.Net2.0)可用的任何USB存储设备和/或CD/DVD刻录机.
How can I discover any USB storage devices and/or CD/DVD writers available at a given time (using C# .Net2.0).
我想为用户提供可以选择用于存储文件以进行物理删除的设备-即不是硬盘驱动器.
I would like to present users with a choice of devices onto which a file can be stored for physically removal - i.e. not the hard drive.
推荐答案
using System.IO;
DriveInfo[] allDrives = DriveInfo.GetDrives();
foreach (DriveInfo d in allDrives)
{
if (d.IsReady && d.DriveType == DriveType.Removable)
{
// This is the drive you want...
}
}
DriveInfo类文档在这里:
The DriveInfo class documentation is here:
http://msdn.microsoft.com/en -us/library/system.io.driveinfo.aspx
这篇关于如何发现USB存储设备和可写CD/DVD驱动器(C#)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文