我的程序在多处调用同一文件路径,有时就提示无法打开文件。请问我该怎么做?

解决方案 »

  1.   

    var   F: TextFile;
    AssignFile(F, OpenDialog1.FileName);   { File selected in dialog box }
        Reset(F);
        Readln(F, S);                          { Read the first line out of the file }
        Edit1.Text := S;                       { Put string in a TEdit control }
        CloseFile(F);
      

  2.   

    使用流来打开读写文件,   TFileStream.Create('文件名',fmOpenReadWrite  or fmShareDenyNone)