2017-10-17 35 views
0

我在写一些JavaScript来更新文本文件的pdf字段。最后让它工作。但现在我发现我无法更新该文本文件,直到我关闭所有的PDF表单。我收到错误消息:“进程无法访问该文件,因为它正在被另一个进程使用。”我正在使用的代码:如何使用javascipt访问文件后发布文件(adobe)

//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”命令后有没有办法释放文件?

回答

0

您需要删除对该文件的引用。将下面的行添加到代码的末尾。

dataStream = null; 
+0

那么,这是一个简单的修复,谢谢。 –