User Tools

Site Tools


finding_20the_20free_20space_20on_20a_20disk

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
finding_20the_20free_20space_20on_20a_20disk [2018/03/31 13:19] – external edit 127.0.0.1finding_20the_20free_20space_20on_20a_20disk [2024/01/05 00:22] (current) – external edit 127.0.0.1
Line 2: Line 2:
  
 //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:\\ \\  //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 bb4w>
         drive$ = "C:\"         drive$ = "C:\"
         SYS "GetDiskFreeSpace", drive$, ^SpC%, ^BpS%, ^Free%, ^Total%         SYS "GetDiskFreeSpace", drive$, ^SpC%, ^BpS%, ^Free%, ^Total%
         gbytes_total = SpC% * BpS% * Total% / 2^30         gbytes_total = SpC% * BpS% * Total% / 2^30
         gbytes_free  = SpC% * BpS% * Free% / 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:\\ \\  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 bb4w>
         PRINT "The disk has ";INT(100*Free%/Total%+0.5);"% free space"         PRINT "The disk has ";INT(100*Free%/Total%+0.5);"% free space"
 +</code>
finding_20the_20free_20space_20on_20a_20disk.1522502360.txt.gz · Last modified: 2024/01/05 00:17 (external edit)