Probably an easy one, but using the getdiskfreespace or getdiskfreespaceex functions returns a value of "4082760192".
How do all you guys (and girls) show this as "4.1GB" for example in your apps?
Thank you!
Alex Read
Printable View
Probably an easy one, but using the getdiskfreespace or getdiskfreespaceex functions returns a value of "4082760192".
How do all you guys (and girls) show this as "4.1GB" for example in your apps?
Thank you!
Alex Read
It returns the number of BYTES on the HD, not MB or GB. To convert, use this:
I know that's not how to use getdiskfreespace, but you get the idea.Code:Function FreeMB() As long
FreeMB = GetDiskFreeSpace("C") / 1024
End Function
FreeMB = GetDiskFreeSpace / 1024
FreeGB = FreeMB /1000
The value is the number of bytes
val/1024 = kb
val/1024^2=mb
val/1024^3=gb etc
even better you can format the final value
gives xx,xxx.xx!Code:val=format(val,"##,##0.00")
Thank you everyone!
Appriciate you writing back. Just one thing, Gravyboy "Byte Me" is this the worst pun we have seen on this site?
Thank you once again!
Alex,
It may well be! GetFreeDiskSpaceEx is the one to use as it has additional abilities, can't remember what they are but they are there!
I noticed quite a few have the ex on, not just withgetdiskfreespace. Why? they do the same function, call on the same dll's. What's the advantage?
Thank you,
confused.
That's from MSDN April 99.Quote:
Windows 95 OSR2 and later:
The GetDiskFreeSpaceEx function is available on Windows 95 systems beginning with OEM Service Release 2 (OSR2). The GetDiskFreeSpaceEx function returns correct values for all volumes, including those that are greater than 2 gigabytes.
Thank you once again. So the main reason is the operability on a wider range of operating systems.
You learn something new every day!
Thank you.