Write binary data with FileSystemObject write()

99封情书 提交于 2019-12-12 11:07:20

问题


I am developing a function in Javascript using FileSystemObject, where I just have to write in a file the binary data we are provided. This is my function.

function exportFile(data)
{   
    var fso, f2;
    fso = new ActiveXObject("Scripting.FileSystemObject");
    f2=fso.CreateTextFile("C:\\example.js",true);
    f2.Write(data);
    f2.Close();
}

Nevertheless it doesn't always work (error on f2.Write(data)). I guess it is because one or both reasons: - Write function does not accept binary data (ASCII from 0-255) - There is a maximum size for "data" in f2.Write(data)

Could you help me, please?

UPDATE:

I get this error (translated): Message: Argument or call to function not valid Which technology should I use, then, if Javascript doesn't work with plain block 8 bit values?


回答1:


FileSystemObject is notably limited, even for writing UTF-8 files satisfactorily I have had to resort to another solution: ADODB.Stream

http://www.w3schools.com/ADO/ado_ref_stream.asp



来源:https://stackoverflow.com/questions/4148437/write-binary-data-with-filesystemobject-write

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