检查txt文件是否已经存在。如果它存在,我想打开并追加。如果!存在,我想创造,打开,写。我不知道该怎么附加文件..。
到目前为止,这是我的代码:
function writeReport(path, reportText) {
var reportFile = new File(path + "/font_report.txt");
if(reportFile.exists){
alert('file already exists');
reportFile.open("w");
reportFile.write(reportText);
reportFile.close();
}
else{
var RCF_file = new File(reportFile);
RCF_file.open("w");
RCF_file.write(reportText);
RCF_file.close();
}
alert('Report Complete');
}if(现有)中的代码显然与其他{}中的代码相同--不确定它应该是什么.
发布于 2017-06-02 20:49:03
为了附加文件,它需要通过附加模式.
reportFile.open("a");https://stackoverflow.com/questions/44336836
复制相似问题