使用 WScript.shell 写入文件
如何使用 WScript 编写文本文件 我对此非常陌生,这就是为什么我无法提供一些详细信息。我想编写一个可以存储在 c://users/user/appdata/local 中的日志文件
我的示例代码,使用 FileSystemObject
function WriteFile()
{
var fso = new ActiveXObject("Scripting.FileSystemObject");
var fh = fso.CreateTextFile("d:\\Test.txt", true);
fh.WriteLine("Some text goes here...");
fh.Close();
}
<body onload = "WriteFile();">
</body>
它确实返回在 d: 中,但在本地 c: 中则不会。
How can I write text files using WScript I'm really new on this that's why I cannot give some details. I want to write a log file that can be stored in c://users/user/appdata/local
my sample code, using FileSystemObject
function WriteFile()
{
var fso = new ActiveXObject("Scripting.FileSystemObject");
var fh = fso.CreateTextFile("d:\\Test.txt", true);
fh.WriteLine("Some text goes here...");
fh.Close();
}
<body onload = "WriteFile();">
</body>
it does return in d: but in local c: it wont.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您在
fh
中缺少一个重要参数。正确的代码是:而
2
是字节码,它告诉fso
写入文件。对于读取值是 1,对于附加值是 8。我想现在您已经清楚了。
You are missing one important parameter in
fh
. The right code is:whereas
2
is a bytecode, which tells tofso
to write a file. For reading value is 1, and for appending value is 8.This is clear to you by now, I suppose.