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

This function 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;
Original resource: The Delphi Pool
Author: Peter Below
Added: 2010/06/02
Last updated: 2010/06/02