Scripting.FileSystemObject 位置(来自 JavaScript)
我的 Windows 侧边栏小工具有一个文件,用于存储用户的一些设置,但 FSO 对象似乎选择其本机位置作为桌面,这意味着如果我不指定目录,它将将此文件放在桌面上。我会指定整个位置,但我希望能够将其放在其他人的计算机上,而无需在桌面上或除小工具文件夹之外的其他位置上放置任何内容。
我知道这在 XMLHttpRequest 中是可能的,但我过去在这方面遇到了麻烦,如果可能的话,如果我能完全避免它会更好。
function writeSetting(text)
{
var fil = new ActiveXObject("Scripting.FileSystemObject");
var writer = fil.OpenTextFile("loc.txt", 2, true);
writer.WriteLine(text);
writer.Close();
}
I have a file for my Windows sidebar gadget that stores some settings for the user, but the FSO object seems to pick its native residence as the desktop, meaning that if I don't specify a directory, it will put this file on the desktop. I would specify the whole location, but I want to be able to put this on other people's computers without having stuff on their desktop or elsewhere besides the gadget folder.
I know this is possible in XMLHttpRequest, but I've had trouble with that in the past, and it would be better if I could just avoid it altogether, if possible.
function writeSetting(text)
{
var fil = new ActiveXObject("Scripting.FileSystemObject");
var writer = fil.OpenTextFile("loc.txt", 2, true);
writer.WriteLine(text);
writer.Close();
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用
System.Gadget.path< /code>
属性来获取小工具的路径并根据需要附加到它。请参阅链接中的示例。
快乐编码。
Use the
System.Gadget.path
property to get the gadget's path and append to it as needed. See the example in the link.Happy coding.