1. Home
  2. Computing & Technology
  3. Delphi Programming
Glossary|Tips/Tricks|FREE App/VCL|Best'O'Net|Books|Link Back

Delphi Programming RTL Reference|By Category|Alphabetically|By Unit
 

DiskFree

unit
Sysutils
category
file management routines

declaration
function DiskFree(Drive: Byte): Int64;

description
Returns the amount of free space in bytes on a specified drive.

DiskFree returns -1 if the drive number is invalid. Drive parameter can be set to: 0 = Current drive, 1 = A, 2 = B, 3 = C and so on.

example
//displays a message indicating the number 
//of KB free, and what percentage of 
//the entire disk space that represents.
var
  S: string;
  AmtFree: Int64;
  Total:   Int64;
begin
  AmtFree := DiskFree(0);
  Total := DiskSize(0);
  S := IntToStr(AmtFree div Total) + 
       'percent of the space on drive 0 is free: ' + 
       (AmtFree div 1024) + ' Kbytes free. ';
  ShowMessage(S);
end;

in real code
Deleting group of files
The code example demonstrates using the SHFileOperation function to copy a group of files and display a progress dialog. You can also use the following flags to delete, move and rename a group of files.

see also
DiskSize


 Free Delphi code snippet inside every Delphi Newsletter!
Subscribe to the Newsletter
Name
Email

 Got some code to share? Got a question? Need some help?
Explore Delphi Programming
About.com Special Features

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. More >

Easy ways to connect two computers for networking purposes. More >

  1. Home
  2. Computing & Technology
  3. Delphi Programming

©2009 About.com, a part of The New York Times Company.

All rights reserved.