Write binary data with FileSystemObject write()

2019-06-23 02:43发布

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条回答
Emotional °昔
2楼-- · 2019-06-23 03:00

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

查看更多
登录 后发表回答