转
uses ShellApi
function GetDirectorySize(Path: String): Integer;
//eg. Path = 'c:/temp/'
var
SR: TSearchRec;
begin
Result := 0;
if FindFirst(Path + '*.*', faAnyFile, SR) = 0 then
begin
if (sr.Name <> '.') and (sr.Name <> '..') and (sr.Attr = faDirectory) then
Result := Result + GetDirectorySize(Path+Sr.Name+'/')
else
Result := Result + Sr.Size;
while FindNext(sr) = 0 do
if (sr.Name <> '.') and (sr.Name <> '..') and (sr.Attr = faDirectory) then
Result := Result + GetdirectorySize(Path+Sr.Name+'/')
else
Result := Result + Sr.Size;
FindClose(sr);
end;
end;