ViaThinkSoft CodeLib
This article is in:
CodeLib → Programming aids → Delphi
function ReadFile(InputFile: string): string;
resourcestring
LNG_COULD_NOT_OPEN_FILE = 'Could not open file "%s".';
var
f: textfile;
tmp: string;
begin
result := '';
if not FileExists(InputFile) then
begin
MessageDlg(Format(LNG_COULD_NOT_OPEN_FILE, [InputFile]), mtError, [mbOk], 0);
Exit;
end;
AssignFile(f, InputFile);
Reset(f);
while not Eof(f) do
begin
ReadLn(f, tmp);
result := result + tmp + #13#10;
end;
CloseFile(f);
end;
Daniel Marschall
ViaThinkSoft Co-Founder
ViaThinkSoft Co-Founder