Visit our Sponsor   Visit our Sponsor
delphi3000.com - the free delphi knowledge platform
delphi3000.com - the free delphi knowledge platform
Have a look at your member-status

connecting people's knowledge


  - Recent ArticlesRSS feed for Recent Articles on delphi3000.com
  - List of All Articles
  - Top Viewed Articles
  - Articles (+Attachem.)
  - Articles Of Interest
  - Categories
  - Top Uploader
  - Search
  - Index

  - My Home
  - Submit an Article
  - My Articles
  - My Personal Data
  - My Bookmarks
  - Activities
  - Login/Logout

  - Sign Up
  - Why Sign Up
  - Newsletter

  - Press
  - Advertise

  - Contact
  - Feedback





Community
Borland
ClubeDelphi
Dr. Bob
UK-BUG
Delphi Meetings
Planeta Delphi







Startblatt.de






Share this article with friendsShare this article with friends
Rate this articleRate this article - to keep the quality of delphi3000.com !
Comment this article or read through previous comments (4)


Retrieving folder sizeFormat this article printer-friendly!Bookmark function is only available for registered users!
Product:
Delphi all versions
Category:
N/A
Skill Level:
Scoring:
Last Update:
06/04/2002
Search Keys:
delphi delphi3000 article borland vcl code-snippet file recursive folder size megabyte
Times Scored:
2
Visits:
2898
Uploader: Christian Cristofori
Company: Function2 by C. Cristofori
Reference: N/A
 
Question/Problem/Abstract:
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:



I'll put here just the code... that isn't very
complicated:

function FolderSize(fld: string):dword;
var
  sr:tsearchrec;
  r:integer;
  s:dword;
begin
  fld:=includetrailingbackslash(fld);
  s:=0;
  r:=findfirst((fld+'*.*'),faanyfile,sr);
  while(r=0)do
  begin
    application.processmessages;
    if((sr.attr and fadirectory)<>0)then
    begin
      if((sr.name<>'.')and(sr.name<>'..'))then
        s:=s+foldersize(fld+sr.name);
    end else
      S:=S+SR.FindData.nFileSizeLow;
    r:=findnext(sr);
  end;
  sysutils.findclose(sr);
  result:=s;
end;





Please rate this article!
Skill level:
BeginnerExpert

Useful:
No!Very!

Overall rating:
PoorExcellent



Comments to this article
Write a new comment
code & dword
    lomix (Feb 2 2005 10:01PM)

tu codigo es como las weas, escribe algo que funcione pa otra vez, te las day qu sabis y no cachai na
Respond

dword -> int64
    Steffen Milz (Jul 6 2003 2:02PM)

The Code is pretty good, but when you have large folders, like 10 GB, a dword value is too small and you shuld use int64 instead!!!
Respond

Thank you
    Hamid Aflaki (Jun 29 2002 11:47AM)

Your function make me very happy today. because today I need to have foldersize in my application . and your faunction save my time .
H.Aflaki
Respond

RE: Thank you
Christian Cristofori (Jul 3 2002 12:40PM)

I'm happy this was useful for you. :)
Respond














 
Sign up to consume product discounts for Bronze memberships !

read more


  Visit our Sponsor

 

  Community Ad of
E. DSpirito
 
   














 







     
  Copyright © 2000 - 2007 delphi3000.com - All rights reserved. Terms of use. || Privacy
delphi3000.com is a service by bluestep.com IT-Services GmbH (Vienna)