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 var3 sr: tsearchrec;
4 r: integer;
5 s: dword;
6 begin7 fld := includetrailingbackslash(fld);
8 s := 0;
9 r := findfirst((fld + '*.*'), faanyfile, sr);
10 while (r = 0) do11 begin12 application.processmessages;
13 if ((sr.attr and fadirectory) <> 0) then14 begin15 if ((sr.name <> '.') and (sr.name <> '..')) then16 s := s + foldersize(fld + sr.name);
17 end18 else19 S := S + SR.FindData.nFileSizeLow;
20 r := findnext(sr);
21 end;
22 sysutils.findclose(sr);
23 result := s;
24 end;