Firefox 附加组件保存到桌面
我正在尝试将文件保存在扩展文件夹之外的文件夹中。现在我正在使用:
var file = Components.classes["@mozilla.org/file/directory_service;1"].
getService(Components.interfaces.nsIProperties).
get("ProfD", Components.interfaces.nsIFile);
if( !file.exists() || !file.isDirectory() ) { // if it doesn't exist, create
file.create(Components.interfaces.nsIFile.DIRECTORY_TYPE, 0777);
}
this.f = file.path+"\\text.txt";
如何更改文件路径以便将其保存在计算机上的其他位置?或者这是不可能的?
谢谢!
I'm trying to save a file in a folder other than the extensions folder. Right now I'm using:
var file = Components.classes["@mozilla.org/file/directory_service;1"].
getService(Components.interfaces.nsIProperties).
get("ProfD", Components.interfaces.nsIFile);
if( !file.exists() || !file.isDirectory() ) { // if it doesn't exist, create
file.create(Components.interfaces.nsIFile.DIRECTORY_TYPE, 0777);
}
this.f = file.path+"\\text.txt";
How can I change the file path so that it saves it somewhere else on the machine? Or is this not possible?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您也可以使用不同的“特殊文件夹”键。有关一些常见问题的列表,请参阅:
https://developer.mozilla.org/en/Code_snippets/File_I%2F %2FO#Getting_special_files
您还可以使用任何绝对路径初始化文件。请参阅:
https://developer. mozilla.org/en/Code_snippets/File_I%2F%2FO#Creating_an_.0ansIFile.0a_object_%28.22opening.22_files%29
You can use different "special folder" keys too. For a list of some common ones, see:
https://developer.mozilla.org/en/Code_snippets/File_I%2F%2FO#Getting_special_files
You can also initialize a file with any absolute path. See:
https://developer.mozilla.org/en/Code_snippets/File_I%2F%2FO#Creating_an_.0ansIFile.0a_object_%28.22opening.22_files%29