using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace demo.ClassHelper { public static class DriveHelper { public static double GetHardDiskSpace(string str_HardDiskName) { long totalSize = 0; str_HardDiskName = str_HardDiskName + ":\\"; System.IO.DriveInfo[] drives = System.IO.DriveInfo.GetDrives(); foreach (System.IO.DriveInfo drive in drives) { if (drive.Name.ToUpper() == str_HardDiskName.ToUpper()) { totalSize = drive.TotalFreeSpace / (1024 * 1024); break; } } return totalSize / 1024.0; } } }