问题
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