Scripting.FileSystemObject 位置(来自 JavaScript)

发布于 2024-11-25 06:34:59 字数 442 浏览 4 评论 0原文

我的 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

寻找我们的幸福 2024-12-02 06:34:59

使用 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文