delphi 写入文本教程代码

procedure TForm1.Button1Click(Sender: TObject); var LogFile: TextFile; begin if not FileExists('c:/Log1.txt') then begin AssignFile(LogFile, 'c:/Log1.txt'); Rewrite(LogFile); CloseFile(LogFile); //关闭时自动保存文件 end; AssignFile(LogFile, 'c:/Log1.txt'); Append(LogFile); writeln(LogFile); writeln(LogFile, '*********End**********'); writeln(LogFile); writeln(LogFile, '********begin*********'); Write(LogFile, 'Begin the same line'); Write(LogFile, '//the same line'); CloseFile(LogFile); end;

你可能感兴趣的:(delphi 写入文本教程代码)