var f : TextFile; begin AssignFile(f, 'c:\aa.txt'); //ReSet(f);Readln(f, s);//读文件 ReWrite(f);//从新写文件 //Append(f)//从原文件尾添加 Write(f, 'aaaaaa');//Writeln()写完后自动回车 CloseFile(f); end;
我写一个示例给你: 这个为向原先的文件加记录! if FileExists(syspath+'data\info.cxj')=false then begin assignfile(flog,syspath+'data\info.cxj'); rewrite(flog); write(flog,''); closefile(flog); close; end; assignfile(flog,syspath+'data\info.cxj'); Append(flog);//这个是重点! Writeln(flog, slog); 好了,绝对正确! 给分吧!!!!!!!!!!!!!!!!!!!!!!!!
1.用Seek指最后 2.写入#13#10既是回车换行 3.用流吧
if FileExists(syspath+'c:\aa.txt')=false then begin assignfile(flog,syspath+'c:\aa.txt'); rewrite(flog); write(flog,''); closefile(flog); close; end; assignfile(flog,syspath+'c:\aa.txt'); Append(flog);//这个是重点! Writeln(flog, slog); 好了,绝对正确!文件都用你的了,只要是文本文件都可以这样的! 给分吧!!!!!!!!!!!!!!!!!!!!!!!!
2。写入#13#10既是回车换行
f : TextFile;
begin
AssignFile(f, 'c:\aa.txt');
//ReSet(f);Readln(f, s);//读文件
ReWrite(f);//从新写文件
//Append(f)//从原文件尾添加
Write(f, 'aaaaaa');//Writeln()写完后自动回车
CloseFile(f);
end;
这个为向原先的文件加记录!
if FileExists(syspath+'data\info.cxj')=false then
begin
assignfile(flog,syspath+'data\info.cxj');
rewrite(flog);
write(flog,'');
closefile(flog);
close;
end;
assignfile(flog,syspath+'data\info.cxj');
Append(flog);//这个是重点!
Writeln(flog, slog);
好了,绝对正确!
给分吧!!!!!!!!!!!!!!!!!!!!!!!!
2.写入#13#10既是回车换行
3.用流吧
begin
assignfile(flog,syspath+'c:\aa.txt');
rewrite(flog);
write(flog,'');
closefile(flog);
close;
end;
assignfile(flog,syspath+'c:\aa.txt');
Append(flog);//这个是重点!
Writeln(flog, slog);
好了,绝对正确!文件都用你的了,只要是文本文件都可以这样的!
给分吧!!!!!!!!!!!!!!!!!!!!!!!!