使用FileSystemObject write()写入二进制数据 [英] Write binary data with FileSystemObject write()
问题描述
我正在使用FileSystemObject用Javascript开发一个函数,在这里我只需要在文件中写入我们提供的二进制数据即可.这是我的职责.
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();
}
尽管如此,它并不总是有效(f2.Write(data)上的错误).我猜是因为其中一个或两个原因: -写入功能不接受二进制数据(0-255之间的ASCII) -f2.Write(data)
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)
可以帮我吗?
更新:
我收到此错误(翻译):消息:参数或函数调用无效 如果Javascript无法使用普通的8位块值,那我应该使用哪种技术?
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?
推荐答案
FileSystemObject
受到显着限制,即使为了令人满意地编写UTF-8文件,我也不得不求助于另一种解决方案:ADODB.Stream
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
这篇关于使用FileSystemObject write()写入二进制数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!