You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

27 lines
755 B
C#

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;
}
}
}