How to check for remaining hard drive space in Windows?
kevinliu23 at gmail.com
Thu Mar 1 01:30:56 CET 2007
Hmmmm, right now...I'm doing multiplication on the index values
returned by GetDiskFreeSpace. According to the documentation...
tuple: sectors per cluster
tuple: number of bytes per sector
tuple: total number of free clusters
tuple: total number of clusters on the disk
So I'm multiplying together indices 0, 1 and 2 together to get the
amount of free space left on my hard drive in bytes. The product of
the first three indices is over 10 gigabytes and is correct according
to my calculations. Why would the documentation say it does not return
data over 2 gigabytes then? Or do you mean not over 2 gigabytes
returned for tuple? I believe my tuple returned a value of
2778727 bytes, which is well below the 2 gigabyte capacity.
Anyway, thanks for letting me know about GetDiskFreeSpaceEx. I will
look into this function as well.
On Feb 28, 5:08 pm, "Jerry Hill" <malaclyp... at gmail.com> wrote:
> On 2/28/07, Tim Golden <m... at timgolden.me.uk> wrote:
> > Well it's not often someone beats me to a WMI
> > solution :) Just to be different, you can also
> > look at the GetDiskFreeSpace function in the
> > win32api module of the pywin32 extensions.
> The MSDN page for that function warns:
> "The GetDiskFreeSpace function cannot report volume sizes that are
> greater than 2 gigabytes (GB). To ensure that your application works
> with large capacity hard drives, use the GetDiskFreeSpaceEx function."
> Make sure to keep that in mind if you're recording free disk space
> someplace, rather than just checking for enough space to do an install
> or something.
More information about the Python-list