Reading a file to a string
Perhaps the easiest way to read a file into a string is using the LoadFromFile method of a TStringList object and then accessing its Text property:
uses SysUtils, Classes;
function LoadFile(const FileName: TFileName): string;
begin
with TStringList.Create do
try
LoadFromFile(FileName);
Result := Text;
finally
Free;
end;
end;
No comments:
Post a Comment