TextFile读写

类别:Delphi 点击:0 评论:0 推荐:

function readFromFile:string;
var s,s2:string; F:TextFile;
begin
  OpenDialog1.FileName:='';
  OpenDialog1.Filter:='*.XML|*.xml'; 
  s:='';  result:='';
  if not OpenDialog1.Execute then exit;

  assignfile(F,OpenDialog1.FileName);
  try
    Reset(F);
    while not Eof(F) do
    begin
      Readln(F, s2);
      s:=s+s2;
    end;
    result:=s;
  finally
    closefile(f);
  end;
end;

procedure writeToFile(s:string);
var F:TextFile;
begin
   assignfile(f,SaveDialog1.fileName);
   try
     rewrite(f);
     writeln(f,s1);
   finally
     closefile(f);
   end;
end;

本文地址:http://com.8s8s.com/it/it4806.htm