我如何使用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:中不会。
您缺少fh
中的一个重要参数。正确的代码是:
var fh = fso.CreateTextFile("d:\Test.txt", 2, true);
而2
是一个字节码,它告诉fso
写一个文件。读取值为1,追加值为8。