Articles   Members Online:
-Article/Tip Search
-News Group Search over 21 Million news group articles.
-Delphi/Pascal
-CBuilder/C++
-C#Builder/C#
-JBuilder/Java
-Kylix
Member Area
-Home
-Account Center
-Top 10 NEW!!
-Submit Article/Tip
-Forums Upgraded!!
-My Articles
-Edit Information
-Login/Logout
-Become a Member
-Why sign up!
-Newsletter
-Chat Online!
-Indexes NEW!!
Employment
-Build your resume
-Find a job
-Post a job
-Resume Search
Contacts
-Contacts
-Feedbacks
-Link to us
-Privacy/Disclaimer
Embarcadero
Visit Embarcadero
Embarcadero Community
JEDI
Links
How to retrieve folder size Turn on/off line numbers in source code. Switch to Orginial background IDE or DSP color Comment or reply to this aritlce/tip for discussion. Bookmark this article to my favorite article(s). Print this article
07-Jan-03
Category
Files Operation
Language
Delphi All Versions
Views
106
User Rating
No Votes
# Votes
0
Replies
0
Publisher:
DSP, Administrator
Reference URL:
DKB
			Author: Christian Cristofori

This function tells you how many bytes a folder, with all subfolders and contained 
files is taking on a HD, CD, floppy or whatever.

Answer:

f
1   unction FolderSize(fld: string): dword;
2   var
3     sr: tsearchrec;
4     r: integer;
5     s: dword;
6   begin
7     fld := includetrailingbackslash(fld);
8     s := 0;
9     r := findfirst((fld + '*.*'), faanyfile, sr);
10    while (r = 0) do
11    begin
12      application.processmessages;
13      if ((sr.attr and fadirectory) <> 0) then
14      begin
15        if ((sr.name <> '.') and (sr.name <> '..')) then
16          s := s + foldersize(fld + sr.name);
17      end
18      else
19        S := S + SR.FindData.nFileSizeLow;
20      r := findnext(sr);
21    end;
22    sysutils.findclose(sr);
23    result := s;
24  end;


			
Vote: How useful do you find this Article/Tip?
Bad Excellent
1 2 3 4 5 6 7 8 9 10

 

Advertisement
Share this page
Advertisement
Download from Google

Copyright © Mendozi Enterprises LLC