文本文件里主要记录时间和当时的运行结果

解决方案 »

  1.   

    var  f: TextFile;
    begin
      if OpenDialog1.Execute then
      begin                    { open a text file }
        AssignFile(f, OpenDialog1.FileName);
        Append(f);
        Writeln(f, 'I am appending some stuff to the end of the file.'); 
        { insert code here that would require a Flush before closing the file }
        Flush(f);  { ensures that the text was actually written to file }
        CloseFile(f);
      end;end;
      

  2.   

    如果记录文件没有的话要使用rewrite来生成一个,因此上面最好为:
    AssignFile(f, FileName);
    try
      Append(f);
    except
      Rewrite(f)
    end;……
      

  3.   

    var
       file:TStrings;
    begin
      file:=TStringList.Create;
      file.Add(DateTimeToString(Now));
      file.SaveToFile('c:\1.txt');
    end;