2003. december 20., szombat
Retrieve folder size
Problem/Question/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:
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;
Feliratkozás:
Megjegyzések küldése (Atom)
Nincsenek megjegyzések:
Megjegyzés küldése