在VBscript中读写二进制文件
我之前使用 ADODB.Stream 来读取和写入二进制文件,这里是
如何在 VBscript 中使用 ADODB.stream 连接二进制文件
它工作正常,唯一的问题是 ADODB.stream 在 Windows 2003 服务器上被禁用,
是否有另一种方法可以读取 3 个二进制文件模式并将它们连接起来或将它们存储在 VBscript 中的一个文件中,
谢谢 日本人
I used earlier ADODB.Stream to read and to write binary file here is the link for that
How to concatenate binary file using ADODB.stream in VBscript
it works fine the only problem is ADODB.stream is disabled on windows 2003 server,
Is there another way i can read 3 files in binary mode and concatenate them or store them in one file in VBscript
thank you
Jp
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
一年前我也遇到过类似的问题。我们知道 TextStream 对象适用于 ANSI 或 Unicode 文本数据,而不是二进制数据;如果流是二进制的,他们的 .readAll() 方法会产生损坏的输出。但有解决方法。将字符一一读取到数组中效果很好。这应该允许您将二进制数据读入 VB 字符串,并将其写回磁盘。当进一步操作此类二进制字符串时,请不要忘记某些操作可能会导致字符串损坏,因为它们仅适用于文本。我总是在使用二进制字符串之前将其转换为整数数组。
I had a similar problem a year ago. We know that the TextStream objects are intended for ANSI or Unicode text data, not binary data; their .readAll() method produces a corrupted output if the stream is binary. But there is workaround. Reading the characters one by one into an array works fine. This should allow you to read binary data into VB strings, and write it back to disk. When further manipulating such binary strings do not forget that certain operations may result into broken strings because they are intended for text only. I for one always convert binary strings into integer arrays before working with them.
基于 Luc125 和 Alberto 的答案,这里有 2 个重新设计和简化的函数:
读取函数
写入函数
Based on Luc125 and Alberto answers here are the 2 reworked and simplified functions:
The Read function
The Write function
ADODB 流对象是 VBScript 读取二进制流的唯一本机方法。如果禁用 ADODB,您将需要安装一些其他第三方组件才能提供相同的功能。
The ADODB stream object is VBScript's only native method of reading binary streams. If ADODB is disabled, you will need to install some other third-party component to provide the same functionality.
ADODB 流对象是 VBScript 读取二进制流的唯一本机方法
ADODB stream object is VBScript's only native method of reading binary streams
可以一起读取所有字节:
It is possible to read all bytes together:
读取 3 个文件 &加入一个文件(没有
ADODB
):在音频、视频、图像、zip 存档和文件上进行测试Win 10 上的 pdf(二进制文件),用于二进制文件复制、编辑、分割、加入、修补和(字节级)加密、编码&压缩。
请参阅示例(答案)此处用于二进制文件修补。
Read 3 files & join to one file (without
ADODB
):Tested on audio, video, image, zip archives & pdf (binaries) on Win 10 for binary file copy, edit, split, join, patching & (byte level) encryption, encoding & compression.
See example (answer) here for binary file patching.