Delphi/CB
•  Greatis •  Security •  AppDatabase •  Utilities •  Visual Basic • .NET •  just4fun
Delphi / C++ Builder
Components, utilities and tips for Delphi and C++ Builder developers
Hot Offer
Save your money!
Featured
Ultimate Pack  hot!
Image Editor  new!
Runtime Fusion
Form Designer
Object Inspector
Print Suite Pro
Commented Image
Delphi Toys
WinDowse
Delphi Bonus
TMS Scripter Studio
Form Designer VB
Form Designer .NET

...get more...
for Delphi.NET, C#, VB.NET
for Delphi VCL, BCB 3-6

News Tips .NET Software VCL Software Partners  

Find out total size of directory
You should specify a directory. After that, you should find all files in this directory by recursion. You should add to the total size the size of each found file.

procedure TForm1.Find(Str: string);
var
  MySearch: TSearchRec;
  FindResult: Integer;
begin
  FindResult:=FindFirst(Str+'\*.*', 
                        faArchive+faHidden+
                        faAnyFile+faVolumeID+
                        faSysFile+faReadOnly+faDirectory,
                        MySearch);
  while FindResult=0 do
  begin
    if (MySearch.Attr=faDirectory) and 
       (MySearch.Name<>'.') and 
       (MySearch.Name<>'..') then
      Find(Str+'\'+MySearch.Name)
    else
      TotalSize:=TotalSize+MySearch.Size;
    FindResult:=FindNext(MySearch);
  end;
  FindClose(MySearch);
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  TotalSize:=0;
  if Length(Edit1.Text)>0 then
  begin
    Find(Edit1.Text);
    Label2.Caption:='Total size = '+IntToStr(TotalSize);
  end;
end;

procedure TForm1.Button2Click(Sender: TObject);
var
  St: string;
begin
  St:='c:\';
  if SelectDirectory(St, [], 0) then
    Edit1.Text:=St;
end;

Related topics
Delete all files within directory
Recognize whether Word is installed
Remove all files from directory

For more
Delphi Help

Download source


Our Partner
DevArchive.com
Recommended
just4fun
Useful Resources
Win32.hlp Online
Unix Manual Pages
MegaDetailed.NET
in3steps.com
Newsletters
Subscribe to our news!    Subscribe to our news!


Greatis Software Greatis | Security | AppDatabase | Utilities | Delphi/CB | Visual Basic | .NET | just4fun

Contacts | Add to Favorites | Recommend to a Friend | Privacy Policy | Copyright © 1998-2008 Greatis Software