I'm using a c# program to see how many GB are still free on a hard drive (total size 1 TB, free size 110 GB (to be exact, according to drive properties in Windows explorer: 118.333.329.408 Bytes) according to Windows).
My problem is that the result I'm getting is.....off.
It's 10,135,252,992 Bytes according to the C# method I'm using below.....but according to Windows 110! GB are free.
Note: I'm talking about a Windows Server
here and the drive is the D drive. So no swap file on it, and no hidden System files (at least not more than any non System drive has as the System drive is the C drive).
public long GetTotalFreeSpace(string driveName)
{
foreach (DriveInfo drive in DriveInfo.GetDrives())
{
if (drive.IsReady && drive.Name == driveName)
{
return drive.TotalFreeSpace;
}
}
return -1;
}
My question here is how can that be and how to correct it?