var
TF: TextFile;
LogFile: string;
txt :string;
sysDir:string;
//創(chuàng)建按鈕
procedure TForm1.Button1Click(Sender: TObject);
begin
sysDir:=extractfilepath(application.ExeName );
if not directoryexists(sysdir+‘log\‘) then
createdir(sysdir+‘log\‘);
logfile:=sysdir+‘log\‘+formatdatetime(‘yyyymmdd‘,now)+‘.txt‘;
end;
//寫日志按鈕
procedure TForm1.Button2Click(Sender: TObject);
begin
//assignfile(logfile,‘log.txt‘);
AssignFile(tf,logfile);
if fileexists(logfile) then
append(tf)
else
rewrite(tf);
writeln(tf,‘123‘);
closefile(tf);
end;