Why does GetDiskFreeSpaceEx return the wrong amount of free space?

Raymond Chen


One customer discovered that viewing the properties of a drive from Explorer shows the amount of disk free space significantly lower than the actual amount of free disk space as resported by the disk management snap-in. The command prompt agrees with Explorer and shows the incorrect result. What’s going on? Not surprisingly, both Explorer and the command prompt use the GetDiskFreeSpaceEx function to get the amount of free disk space. (It’s not surprising because the only two convenient options are GetDiskFreeSpace and GetDiskFreeSpaceEx, and the former exists only for compatibility with older programs who don’t support drives bigger than 2GB.) If you go to the documentation for the GetDiskFreeSpaceEx function, you’ll see that the amount of free disk space reported is not the actual amount of physical free disk space but rather the amount of available physical free disk space as constrained by the user’s quota.

Just saying the word “quotas” to the customer was enough to satisfy them. I guess that was enough of a nudge that they could figure out the rest for themselves.


Comments are closed. Login to edit/delete your existing comments