November 1st, 2007

Why does GetDiskFreeSpaceEx return the wrong amount of free space?

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.

Topics
Code

Author

Raymond has been involved in the evolution of Windows for more than 30 years. In 2003, he began a Web site known as The Old New Thing which has grown in popularity far beyond his wildest imagination, a development which still gives him the heebie-jeebies. The Web site spawned a book, coincidentally also titled The Old New Thing (Addison Wesley 2007). He occasionally appears on the Windows Dev Docs Twitter account to tell stories which convey no useful information.

0 comments

Discussion are closed.