Can't write to file NS_ERROR_FILE_UNRECOGNIZED_PATH

扶醉桌前 提交于 2019-12-24 05:44:10

问题


I try to write in file using sdk.

var fs = require('sdk/io/fs');

fs.writeFile('text.ini', '123', null, function (error) {
  callback(error);
});

But i obtain NS_ERROR_FILE_UNRECOGNIZED_PATH. Which path should I use?


回答1:


You can obtain special directories' path with sdk/system.

const { pathFor } = require('sdk/system')
const path = require('sdk/fs/path'); // important for cross-platform compatibility 

var profile = pathFor('ProfD');
var filepath = path.join(profile, 'text.ini');

// now pass filepath to writeFile


来源:https://stackoverflow.com/questions/22692369/cant-write-to-file-ns-error-file-unrecognized-path

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!