MirceaVleju
Programmer
Is there a function that gives the total size of a folder?
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
function GetTreeSize ( path: string ): integer;
var
tsr: TSearchRec;
begin
result := 0;
path := IncludeTrailingBackSlash ( path );
if FindFirst ( path + '*', faAnyFile, tsr ) = 0 then begin
repeat
if ( tsr.attr and faDirectory ) > 0 then begin
if ( tsr.name <> '.' ) and ( tsr.name <> '..' ) then
inc ( result, GetTreeSize ( path + tsr.name ) );
end
else
inc ( result, tsr.size );
until FindNext ( tsr ) <> 0;
FindClose ( tsr );
end;
end;