现在的位置: 首页 > 综合 > 正文

delphi7 读写txt

2013年03月10日 ⁄ 综合 ⁄ 共 573字 ⁄ 字号 评论关闭
30元程序员衣装优惠券,仅剩3天!点击领取

 

procedure TForm1.newClick(Sender: TObject);
var
f:textfile;
filename:string;
begin
  filename:='a.txt';
  if not fileexists(filename) then
  begin
    assignfile(f,filename);
    rewrite(f);
    closefile(f);
    e.Text:='ok';
  end;

end;

procedure TForm1.Button2Click(Sender: TObject);
var
f:textfile;
filename:string;
begin
  filename:='a.txt';
  assignfile(f,filename);
  rewrite(f);
  writeln(f,'aa');
  closefile(f);
end;

procedure TForm1.Button1Click(Sender: TObject);
var
f:textfile;
filename:string;
str:string;
begin
  filename:='a.txt';
  assignfile(f,filename);
  reset(f);
  readln(f,str);
  closefile(f);
  e.Text:=str;
end;

30元程>序员衣装优惠券,仅剩3天!点击领取

抱歉!评论已关闭.