本文阐述了阅读和写作的Jscript的二进制
文件的
方法,
分享给你
参考。具体实现的方法如下:
新数组(256);
对于(var i = 0;i < 256;i + +){
本{我} = String.fromCharCode(我);
}
功能testwrite(){
无功流=新的ActiveX对象(数据流);
无功adtypebinary = 1,adTypeText = 2;
类型= adTypeText流;
stream.charset =ISO-8859-1;
流。打开();
/ / stream.writetext(设备 X01 X02 xff xff );
对于(var i = 0;i < 256;i + +){
Stream.WriteText(String.fromCharCode(我));
/ / stream.writetext(仓{我});
}
stream.savetofile(C: Windows
温度 测试。斌
流。
关闭();
流=空;
}
函数的BinaryFile(
路径){
无功adtypebinary = 1,adTypeText = 2;
无功adsavecreatenotexist = 1,adsavecreateoverwrite = 2;
无功adreadall = - 1,adreadline = - 2;
这个路径=文件路径;
this.writeall =功能(内容){
无功流=新的ActiveX对象(数据流);
类型= adTypeText流;
stream.charset =ISO-8859-1;
流。打开();
Stream.WriteText(内容);
Stream.SaveToFile(this.path,adsavecreateoverwrite);
流。关闭();
流=空;
}
this.readall =函数(){
无功流=新的ActiveX对象(数据流);
类型= adTypeText流;
stream.charset =ISO-8859-1;
流。打开();
Stream.LoadFromFile(这个路径);
无功量= Stream.ReadText(adreadall);
流。关闭();
流=空;
返回内容;
}
}
示例如下:
无功crfolder = c: / /铬的温度
VaR BF1 =新binaryfile(crfolder + / pcdv0026 .webp);
VaR BF2 =新binaryfile(crfolder + / pcdv0026_ .webp);
bf2.writeall(bf1.readall());
希望本文能对大家的javascript
程序设计有所帮助。