Eph*_*aim 5 c# usb hard-drive getdrivetype
我想检索系统中的固定磁盘列表.但C#的GetDrives固定驱动器包括插头USB硬盘.
知道如何检测到固定驱动器不是USB硬盘或反之亦然吗?
使用 DriveType 检测驱动器的类型:
using System.IO;
DriveInfo[] allDrives = DriveInfo.GetDrives();
foreach (DriveInfo d in allDrives)
{
if (d.IsReady && d.DriveType == DriveType.Fixed)
{
// This is the drive you want...
}
}
Run Code Online (Sandbox Code Playgroud)
编辑1:
检查以下链接: 如何检测硬盘驱动器是否通过 USB 连接?
| 归档时间: |
|
| 查看次数: |
5021 次 |
| 最近记录: |