private static long FreeSpaceOnDrive(string path) { long res = 0; string root = string.Empty; if (Path.IsPathRooted(path)) { root = Path.GetPathRoot(path); DriveInfo[] drives = System.IO.DriveInfo.GetDrives(); foreach (DriveInfo drive in drives) { if (root.Equals(Path.GetPathRoot(drive.Name), StringComparison.InvariantCultureIgnoreCase)) { if (drive.IsReady) { res = drive.AvailableFreeSpace; break; } } } } return res; }
No comments:
Post a Comment