主要是IsReady的判断:
public void InitDirveList()
...{
String str;
foreach (DriveInfo drive in DriveInfo .GetDrives())
...{
if (drive.IsReady)
...{
str = drive.Name + " ";
str += drive.DriveFormat + " ";
str += "类型:" + drive.DriveType;
comboBox1.Items.Add(str);
}
}
}
...{
String str;
foreach (DriveInfo drive in DriveInfo .GetDrives())
...{
if (drive.IsReady)
...{
str = drive.Name + " ";
str += drive.DriveFormat + " ";
str += "类型:" + drive.DriveType;
comboBox1.Items.Add(str);
}
}
}
另外,DriveInfo还可以得到很多关于驱动器的信息,比如自由空间等等。
(转载注明出处:http://blog.csdn.net/blog51)