本文介绍了无法写入文件NS_ERROR_FILE_UNRECOGNIZED_PATH的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试使用sdk写入文件。

来获得特殊目录的路径。

$ b

const {pathFor} = require('sdk / system')
const path = require('sdk / fs / path'); //对跨平台兼容性很重要

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

//现在传递文件路径到writeFile


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?

解决方案

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

这篇关于无法写入文件NS_ERROR_FILE_UNRECOGNIZED_PATH的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-17 09:30