我有一个允许应用程序总共获得硬盘大小的功能。
public static ulong GetLogicalDisk()
{
ulong num = 0L;
string[] logicalDrives = Environment.GetLogicalDrives();
for (int i = 0; i < logicalDrives.Length; i++)
{
System.IO.DriveInfo info = new System.IO.DriveInfo(logicalDrives[i].ToString());
if (info.DriveType == System.IO.DriveType.Fixed)
{
num += (ulong)info.TotalSize; //Exception here.
Console.WriteLine(info.TotalSize);
}
}
Console.WriteLine(num);
return num;
}
当我尝试在C#中启动应用程序时,我在num += (ulong)info.TotalSize;
上收到以下错误消息
IOException未处理
这里的任何人都可以帮我吗?有什么问题?