Using “FSO” in Javascript, how to write a variables's content to a file? [duplicate]

牧云@^-^@ 提交于 2019-12-02 13:34:06

Here's one way:

makefile();

function makefile () {

    var fso = new ActiveXObject("Scripting.FileSystemObject"),
        thefile=fso.CreateTextFile("C:\\temp\\MyFile.txt",true);

    thefile.WriteLine('abc');
    thefile.Close();
}

Bear in mind this will only work in IE with the correct "relaxed" security permissions.

All the information can be found under FileSystemObject Basics.

When you CreateTextFile (or OpenAsTextStream in write mode) you get a TextStream object back which has a WriteLine method, among others. Please see the examples for "the code".

Happy coding.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!