delphi怎么把一个字符串变量保存到一个文本文件中? delphi怎么把一个字符串变量保存到一个文本文件中? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 用ini文件,看ini的读写对应的类就知道了或者var s:string; sl:Tstringlist;begin sl:=Tstringlist.create; sl.add(s); sl.savetofile('c:\test.txt'); sl.free;end; procedure TForm1.Button1Click(Sender: TObject);var afile: TFileStream;begin if not FileExists('c:\a.txt') then begin try afile := TFileStream.Create('c:\a.txt', fmCreate); afile.WriteBuffer(PChar(Edit1.Text + #13#10)^, Length(Edit1.Text + #13#10)); finally afile.Free; end; end else begin try afile := TFileStream.Create('c:\a.txt', fmOpenWrite); afile.Seek(0, soEnd); afile.WriteBuffer(PChar(Edit1.Text + #13#10)^, Length(Edit1.Text + #13#10)); finally afile.Free; end; end;end;这样就可以了!不过这个只是例子!还要修改! 问个简单的问题MainMenu idudpserver发送信息问题 sQl问题(10万火急) 谁有港口物流方面的用例分析?高价求购 RS-232 做什么样的查询窗体好 ......一个弱弱的问题.....(在线等。。。) 各位帮我看一下,treeview中的递归建树的问题,谢谢,50分 两个TDateTime之间的差距的整数部分,是否可视为它们之间的天数? 如何在报表中生成柱形图,波形图等,请给个实例? Delphi安装程序的制作 请问如何去除系统中的一个类名.
或者
var
s:string;
sl:Tstringlist;
begin
sl:=Tstringlist.create;
sl.add(s);
sl.savetofile('c:\test.txt');
sl.free;
end;
var
afile: TFileStream;
begin
if not FileExists('c:\a.txt') then
begin
try
afile := TFileStream.Create('c:\a.txt', fmCreate);
afile.WriteBuffer(PChar(Edit1.Text + #13#10)^, Length(Edit1.Text + #13#10));
finally
afile.Free;
end;
end
else begin
try
afile := TFileStream.Create('c:\a.txt', fmOpenWrite);
afile.Seek(0, soEnd);
afile.WriteBuffer(PChar(Edit1.Text + #13#10)^, Length(Edit1.Text + #13#10));
finally
afile.Free;
end;
end;
end;
这样就可以了!不过这个只是例子!还要修改!