如何在给定时间发现可用的任何USB存储设备和/或CD/DVD刻录机(使用C#.Net2.0).
我想向用户提供可以存储文件以便物理移除的设备选择 - 即不是硬盘驱动器.
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...
}
}
Run Code Online (Sandbox Code Playgroud)
DriveInfo类文档在这里:
http://msdn.microsoft.com/en-us/library/system.io.driveinfo.aspx
| 归档时间: |
|
| 查看次数: |
5997 次 |
| 最近记录: |