How can i get the size of a folder in Firemonkey?

  

I want to calculate the size of a folder in android. I have tried this

function GetDirSize(dir: string; subdir: Boolean): Longint;
var
rec: TSearchRec;
found: Integer;
begin
Result := 0;
if dir[Length(dir)] <> ” then dir := dir + ”;
found := FindFirst(dir + ‘*.*’, faAnyFile, rec);
while found = 0 do
begin
Inc(Result, rec.Size);
if (rec.Attr and faDirectory > 0) and (rec.Name[1] <> ‘.’)
and (subdir = True) then
Inc(Result, GetDirSize(dir + rec.Name, True));
found := FindNext(rec);
end;
FindClose(rec);
end;

This is giving incorrect size in android but giving correct size in windows Platform.Is there any other way to findout the size for android?

Comments are closed.