用OpenDialog和SaveDialog控件实现文件的打开和保存,下面的程序只用了OpenDialog控件,保存也是很简单的
procedure TForm1.RzButtonEditTempPath1ButtonClick(Sender: TObject);
var
filename:string;
tips:tstringlist;
begin
OpenDialog1.Execute;
if trim(OpenDialog1.FileName)<>'' then
RzButtonEditTempPath1.Text := OpenDialog1.FileName;
filename:= OpenDialog1.FileName;
tips:=tstringlist.create;
tips.loadfromfile(filename);
//tips.loadfromfile('filename.txt');
RzEdit1.text:=tips[0];
tips.add('last line addition string');
tips.insert(1,'insert string at NO 2 line');
tips.savetofile('newfile.txt');
tips.free;
end;