procedure TForm1.FormCreate(Sender: TObject);
var
   fnam,sa:string;
   hha:textfile;
begin
  fNam := ExtractFilePath(Application.ExeName)+'wchb.txt';
  if not FileExists(fNam) then
    begin
      FileCreate(fNam);
      assignfile(hha,fnam);
      append(hha);  //为什么这一行一直说“I/O error 32”呢???????????
      writeln (hha,'*******************************************************');
      flush(hha);
      closefile(hha);
    end;
end;
为什么一直说“I/O error 32”呢???????????????
?????????????????????????????????????????????????????????????????
帮俺搞一下了啊??????

解决方案 »

  1.   

    fNam := ExtractFilePath(Application.ExeName)+'wchb.txt';
      if not FileExists(fNam) then
        begin
        i:= FileCreate(fNam);//此时文件已经打开
        FileClose(i);//关闭后     assignfile(hha,fnam);//此处才能起作用
          append(hha);  //为什么这一行一直说“I/O error 32”呢???????????
          writeln (hha,'*******************************************************');
          flush(hha);
          closefile(hha);
        end;
    end;
      

  2.   

    fNam := ExtractFilePath(Application.ExeName)+'wchb.txt';
      if not FileExists(fNam) then
        begin
        i:= FileCreate(fNam);
        FileWrite(i,'dddd');
        FileClose(i);{    // assignfile(hha,fnam);
        //  append(hha);  //为什么这一行一直说“I/O error 32”呢???????????
        //  writeln (hha,'*******************************************************');
          flush(hha);
          closefile(hha);}
        end;
    end;
      

  3.   

    你的错误是Filecreate,此文件已经打开了,
    assignFile时已经出错了,不是append出错
      

  4.   

    AssignFile(hha, fnam);
      ReWrite(hha);
      MessageBox(handle, PChar('文件' + fnam+ '创建成功!'), '提示', mb_iconWarning + mb_Ok);
      CloseFile(hha);
    然后再进行你的操作