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

finding_20the_20free_20space_20on_20a_20disk [2018/03/31 13:19]
127.0.0.1 external edit
finding_20the_20free_20space_20on_20a_20disk [2018/04/17 16:09] (current)
tbest3112 Added syntax highlighting
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.txt ยท Last modified: 2018/04/17 16:09 by tbest3112