📜  c# 获取驱动器上的可用空间 - C# 代码示例

📅  最后修改于: 2022-03-11 14:49:10.084000             🧑  作者: Mango

代码示例1
using System.IO;

private long GetTotalFreeSpace(string driveName)
{
    foreach (DriveInfo drive in DriveInfo.GetDrives())
    {
        if (drive.IsReady && drive.Name == driveName)
        {
            return drive.TotalFreeSpace;
        }
    }
    return -1;
}