SmartPascal
DiskFree
Function
Gives the number of free bytes on a specified drive SysUtils unit
 function DiskFree ( Drive : Byte ) : Int64;
Description
The DiskFree function gives the amount of free space on Drive.
 
If the drive is invalid, or does not contain media, -1 is returned
 
If the drive is read-only, 0 is returned.
 
The Drive is designated as follows:
 
= A drive
= B drive
= C drive
... 
Related commands
DiskSize Gives the size in bytes of a specified drive
 
Example code : Show the free space on drives B to F on your PC
var
  i     : Integer;
  space : Int64;

begin
  // Display the free space on drives B, C, D, E, F, where present
  for i := 2 to 6 do
  begin
    space := DiskFree(i);

    if space >= 0
    then ShowMessage(Chr(i+64)+' Drive free space = '+
                     FloatToStrF(space, ffNumber, 20, 0))
    else ShowMessage(Chr(i+64)+' Drive not present');
  end;
end;
Show full unit code
   Example output is as follows:
  
   B Drive not present
   C Drive free space = 8,414,223,678
   D Drive free space = 4,127,004,529
   E Drive free space = 0
   F Drive free space = 0