Title: Retrieving folder size
Question: 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;