我发现以下帖子给出了我想要的反转(how to find the free percentage of a drive in c#),但我不能完全理解如何以百分比的形式返回驱动器的USED空间
答案 0 :(得分:1)
它与链接的答案几乎相同,如
DriveInfo drive = new DriveInfo("C");
double percentFree = 100 * (double)(drive.TotalSize - drive.AvailableFreeSpace) / drive.TotalSize;
答案 1 :(得分:0)
DriveInfo drive = new DriveInfo("C");
var totalUsed = drive.TotalSize-drive.TotalFreeSpace;
var percentUsed = 100 * (double)totalUsed / drive.TotalSize;