DelayTime(10);是延时函数:
procedure TForm1.DelayTime(DeTime:integer);
var
 bt:Integer;
begin
    bt:=Gettickcount;
    while gettickcount<bt+DeTime do
         application.ProcessMessages;
end; 

解决方案 »

  1.   

    应该先 判断是否存在此文件,如果没有的话,可以用rewrite创建以下!!然后在用append函数!!!
      

  2.   

    可以直接用函数rewrite创建文件,然后再write
      

  3.   

    你创建的文件和你打开的是一个文件吗?createfile有什么用呢?既然用了那还用AssignFile干什么?两者用一个就解决问题了!
      

  4.   

    我是这样想的:
      用createfile先创建一个文本文件,然后后用assingfile去关联这文件和文件变量:
    代码如下:CreateFile(             pchar('F:/专题文件/'+keystring+'/'+keystring+'.txt'),    
                      GENERIC_WRITE or Generic_read    ,    
                      FILE_SHARE_WRITE,    // share mode
                      nil,    // pointer to security attributes
                      CREATE_ALWAYS    ,    // how to create
                      FILE_ATTRIBUTE_NORMAL    ,    // file attributes
                      0    // handle to file with attributes to copy
                     );     AssignFile(MyTextFile,Keystring+'.txt‘);
         Rewrite(MyTextFile);
         adoquery1.First;
      try
         For i:=0 to adoquery1.RecordCount-1 do
             begin
                   info_name:=adoquery1['Info_Name'];
                   info_month:=adoquery1['info_month'];
                   writeln(MyTextFile,'Name       ',info_name);
                   writeln(MyTextFile,'Time       ',info_time);
                   adoquery1.Next ;
                   DelayTime(10);
             end;
      finally
             begin
                  closeFile(MyTextFile);
                 showmessage('列表清单已经写完');
             end;出现'列表清单已经写完';对话框后我去打开创建的文本文件说正被另一个程序占用,
    但就是没向里写东西呀!
      

  5.   

    你没有关闭文件
    不要用Finally
    试试
      

  6.   

    var
    mytextfile:filetext;
    i:integer;
    begin
     
    AssignFile(MyTextFile,'Risk.txt');
    if existsfile('risk.txt') then
        Append(MyTextFile)
    else
       rewrite(mytextfile);
         adoquery1.First;
      try
         For i:=0 to adoquery1.RecordCount-1 do
             begin
                   info_name:=adoquery1['Info_Name'];
                   info_month:=adoquery1['info_month'];
                   writeln(MyTextFile,'Name       ');
                   writeln(MyTextFile,'Time       ');
                   adoquery1.Next ;
              end;
      finally
             begin
                 closeFile(MyTextFile);
                 showmessage('列表清单已经写完');
             end;