1、定义类型
var
F: TextFile;
Logfile: string;
txt :string;
2、代码
//创建目录
if not directoryexists(_AppPath + 'Error/') then
createdir(_AppPath + 'Error/');
LogFile := _AppPath + 'Error/' + FormatDateTim('YYYYMMDD',Date) + '.txt';
//写日志文件
AssignFile(F, LogFile);
if FileExists(LogFile) then
Append(F)
else
Rewrite(F);
//开始写入
Writeln(F, txt);
//结束
CloseFile(F);