ReWrite überschriebt eine bestehende Datei.
So sollte es gehen:
Delphi-Quellcode:
var
LogFile: TextFile;
sFileName : String;
begin
Log.Lines.Add('---------------------------------------------------');
Log.Lines.Add('Log wird gespeichert: am '+DateTostr(date)+' um '+TimeStr+' Uhr.');
Log.Lines.Add('---------------------------------------------------');
if not DirectoryExists('data\log')
then CreateDir('date\log');
sFileName := 'data\log\'+DateToStr(Date)+'.log';
AssignFile(LogFile,sFileName);
If FileExits(sFileName) Then append(LogFile) Else ReWrite(LogFile);
writeln(logfile, log.Text);
closefile(logfile);
end;