[英]Get free disk space in two loop
I'm looking for a way to get disk size information in two cycles, but I'm having difficulty.我正在寻找一种在两个周期内获取磁盘大小信息的方法,但我遇到了困难。 TotalFreeSpace not recognized. 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;
}
}
}
After placing this code in my own IDE, the error is not that the property TotalFreeSpace is not recognized.把这段代码放到我自己的IDE中后,报错不是TotalFreeSpace这个属性不识别。 It says you cannot implicitly cast long to string.它说您不能将 long 隐式转换为字符串。
Solution would be:解决方案是:
string Size = d.TotalFreeSpace.ToString();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.