获取磁盘分区

时间:2014-04-08 15:52:12

标签: c# .net

我希望系统中的所有分区都可用。这段代码只返回一个分区。

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);
    }
}

0 个答案:

没有答案