Kdyz v Delphi pouziju nasledujici funkci, vyhodnoceni Program Files trva 3 sekundy, Salamanderu to trva 20 sekund. Jsem si vědom, že Salamander vyhodnocuje i velikost komprimovanou, ale že by to měl být takový overhead... nevím, zhodnoťte sami.
function DirectorySize(DirPath: string): Int64;
var
SearchItem: TSearchRec;
ErrorCode: Integer;
begin
Result := 0;
if not DirectoryExists(DirPath) then
raise Exception.Create('Invalid path: ' + sLineBreak + DirPath);
DirPath := IncludeTrailingPathDelimiter(DirPath);
ErrorCode := FindFirst(DirPath + '*.*', faAnyFile, SearchItem);
try
while ErrorCode = 0 do begin
if SearchItem.Attr and faDirectory = 0
then Result := Result + SearchItem.Size
else if (SearchItem.Name <> '.') and (SearchItem.Name <> '..')
then Result := Result + DirectorySize(DirPath + SearchItem.Name);
ErrorCode := FindNext(SearchItem);
end;
finally
FindClose(SearchItem);
end;
end;
Rychlejší funkce na zjištění velikosti adresáře
-
- Posts: 1
- Joined: 20 Nov 2014, 09:04
Re: Rychlejší funkce na zjištění velikosti adresáře
A jak dlho počíta veľkosť toho istého adresára Explorer?