Finding+the+free+space+on+a+disk

//by Richard Russell, October 2006//

If you need to find out the amount of free space on a disk drive you can do that quite easily:

code format="bb4w" drive$ = "C:\" SYS "GetDiskFreeSpace", drive$, ^SpC%, ^BpS%, ^Free%, ^Total% gbytes_total = SpC% * BpS% * Total% / 2^30 gbytes_free = SpC% * BpS% * Free% / 2^30 code This code fragment sets **gbytes_total** to the total capacity of the drive and **gbytes_free** to the free (unused) space on the drive, both in Gigabytes.

If you only want to know the free space as a percentage of the total you don't need to calculate the values in Gbytes but simply use the **Free%** and **Total%** values:

code format="bb4w" PRINT "The disk has ";INT(100*Free%/Total%+0.5);"% free space" code