如何在使用JavaScript(adobe)访问文件后释放文件

如何在使用JavaScript(adobe)访问文件后释放文件,javascript,pdf,Javascript,Pdf,我正在编写一些javascript来更新文本文件中的pdf字段。终于开始工作了。但现在我发现,在我关闭所有pdf表单之前,我无法更新该文本文件。我得到一个错误: “该进程无法访问该文件,因为其他进程正在使用该文件。” 我正在使用的代码: //Grab the current path and update it to indicate the TempInfo location var strPath = this.path; strPath = strPath.slice(0,-1

我正在编写一些javascript来更新文本文件中的pdf字段。终于开始工作了。但现在我发现,在我关闭所有pdf表单之前,我无法更新该文本文件。我得到一个错误:

“该进程无法访问该文件,因为其他进程正在使用该文件。”

我正在使用的代码:

  //Grab the current path and update it to indicate the TempInfo location
  var strPath = this.path;
  strPath = strPath.slice(0,-12);
  strPath = strPath + "TempInfo.txt"

  //Get data from TempFile into array, display message if no file found
  try{
    var dataStream = util.readFileIntoStream(strPath);
    var dataFrom = util.stringFromStream(dataStream);
  }catch(e){
  app.alert("Temp file not found");
  }

  //Put the data into an array and update the field
  var strTest = new Array();
  strTest = dataFrom.split(/\n/);

  getField("Username").value = strTest[0];

使用“util”命令后是否有办法释放文件?

您需要删除对文件的引用。在代码末尾添加以下行

dataStream = null;