我正在寻找一种在两个周期内获取磁盘大小信息的方法,但我遇到了困难。TotalFreeSpace 无法识别。
List<string> NamesDrive = new List<string>();
string[] LogicalDrives = System.IO.Directory.GetLogicalDrives();
foreach (string Disk in LogicalDrives)
{
NamesDrive.Add(Disk);
}
DriveInfo[] allDrives = DriveInfo.GetDrives();
foreach (DriveInfo d in allDrives)
{
foreach (string i in NamesDrive)
{
if (d.Name == i)
{
string Size = d.TotalFreeSpace;
}
}
}