Mirror

How to get the size of a text file without opening it (Views: 710)


Problem/Question/Abstract:

How to get the size of a text file without opening it

Answer:

Returns the size, in bytes, of the passed file:

function TextfileSize(const name: string): LongInt;
var
  SRec: TSearchRec;
begin
  if FindFirst(name, faAnyfile, SRec) = 0 then
  begin
    Result := SRec.Size;
    Sysutils.FindClose(SRec);
  end
  else
    Result := 0;
end;

<< Back to main page