我希望系统中的所有分区都可用。这段代码只返回一个分区。
string[] arr = new string[4];
ListViewItem itm;
DriveInfo[] allDrives = DriveInfo.GetDrives();
foreach (DriveInfo d in allDrives)
{
if (d.IsReady == true)
{
arr[0] = d.Name;
arr[1] = d.DriveType.ToString();
arr[2] = d.TotalSize.ToString();
arr[3] = d.DriveFormat;
itm = new ListViewItem(arr);
listView1.Items.Add(itm);
}
}