c#怎么获取USB储存设备,比如U盘/移动硬盘/硬盘盒(硬盘)/内存卡都获取出盘符
1个回答
展开全部
在WMI中,通过Win32_DiskDrive对象可以获团困取磁盘慧老驱动器的相关信息:
ManagementClass mc = new ManagementClass("塌碧念Win32_DiskDrive");
ManagementObjectCollection moc = mc.GetInstances();
foreach (ManagementObject mo in moc)
{
propertyInfo = mo.Properties[PropertyName].Value.ToString();
}
ManagementClass mc = new ManagementClass("塌碧念Win32_DiskDrive");
ManagementObjectCollection moc = mc.GetInstances();
foreach (ManagementObject mo in moc)
{
propertyInfo = mo.Properties[PropertyName].Value.ToString();
}
更多追问追答
追问
PropertyName不存在怎么办?
追答
PropertyName 是属性名称,要自己填写
比如获取硬盘序列号,就是
HardDiskSerialNumber = mo.Properties["SerialNumber"].Value.ToString();
http://blog.csdn.net/taozpwater/article/details/8050529
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询