function GetDirectorySize(Dir: String): Double; var SR: TSearchRec; I: Integer; begin Dir := IncludeTrailingBackSlash(Dir);
I := FindFirst(Dir + '*.*', faAnyFile, SR); while I = 0 do begin if (SR.Name[1] <> '.') then //exclude '.' and '..' directories begin if (SR.Attr and faDirectory) = faDirectory then Result := Result + GetDirectorySize(Dir + SR.Name) //calculate size of nested directory else Result := Result + SR.Size; end; {if Name <> '.'} I := FindNext(SR); end; {while I = 0}