Alternativ ohne Streams geht es auch mit den Proceduren die ich mir mal geschrieben habe und seitdem benutze:
Delphi-Quellcode:
{-----------------------------------------------------------------------------
Description: Schreibt in eine TXT rein
Procedure: intxtschreiben
Arguments: text:string; pfad:string=''; vorherloschen:boolean=true
Result: None
Detailed description:
-----------------------------------------------------------------------------}
procedure intxtschreiben(text:string; pfad:string=''; const endung:string='.txt'; vorherloschen:boolean=true);
var txt:textfile;
begin
if pfad='' then
pfad:=ExtractFilePath(Application.ExeName)+dateToStr(now)+' '+inttostr(hourof(now))+'h '+inttostr(minuteof(now))+'m '+inttostr(secondof(now))+'s '+endung
else
DelDubbleExtension(pfad,endung);
try
try
assignfile(txt,pfad);
if (fileexists(pfad))and(not vorherloschen) then
append(txt)
else
rewrite(txt);
writeln(txt,text);
finally
closefile(txt);
end;
except
showmessage('Es konnte keine Datei erstellt werden!'+chr(13)+
'Falls Sie das Programm von CD Starten kopieren Sie bitte die *.exe auf ihre Festplatte und starten Sie erneut!');
end;
end;
{-----------------------------------------------------------------------------
Description:
Procedure: readtxt
Arguments: path:string
Result: string
Detailed description:
-----------------------------------------------------------------------------}
function readtxt(path:string):string;
var txt:textfile;
s:string;
begin
result:='';
if fileexists(path) then
try
assignfile(txt,path);
reset(txt);
repeat
readln(txt,s);
result:=result+s+#13+#10;
until eof(txt);
finally
closefile(txt);
end;
end;
Gruß Alexander