WEB开发网
开发学院软件开发Delphi TextFile读写 阅读

TextFile读写

 2006-02-04 13:51:09 来源:WEB开发网   
核心提示:function readFromFile:string;var s,s2:string; F:TextFile; begin OpenDialog1.FileName:=''; OpenDialog1.Filter:='*.xml|*.xml'; s:='';

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;

Tags:TextFile 读写

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接