using System.IO;
DriveInfo[] drive = DriveInfo.GetDrives();
for (int i = 0; i < drive.Length;i++ )
{
if (drive[i].IsReady)
{
drive[i].Name //名称
drive[i].TotalSize //大小
drive[i].TotalFreeSpace //剩余空间
}
}
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
namespace WindowsApplication3
{
public class FindUSB
{
public static List
{
List
DriveInfo[] myAllDrives = DriveInfo.GetDrives();
foreach (DriveInfo myDrive in myAllDrives) {
if (myDrive.IsReady) {
if (myDrive.DriveType == DriveType.Removable) {
driverList.Add(myDrive.Name);
}
}
}
return driverList;
}
}
}
[DllImport("kernel32.dll")]
要声明你引用了哪个DLL好像。。。