如何读取文件作为Birary String vb.net [英] How to Read Write Files As Birary String vb.net

查看:72
本文介绍了如何读取文件作为Birary String vb.net的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何将文件读取为二进制并将其转换为字符串并将其保存到txt文件将读取的字符串作为二进制文件然后作为文件?

How Can I Read File As Binary And Covert It To String And Save It To txt file the read string as Binary then as file ?

推荐答案

您可以阅读并且非常容易地将数据写为二进制:

You can read and write data as binary very easily:
Dim data As Byte() = File.ReadAllBytes(path)
...
File.WriteAllBytes(path, data)

问题是将它转换为字符串需要更多的知识:特别是您正在阅读的数据的格式以及您想要用作字符串的格式。字节是8位十六进制值,但字符串由字符组成 - 大部分是16位Unicode值,它可能不仅仅是读取字节,视为字符的情况 - 作为字符串得到的结果或者文本文件可能不是你所期望的,甚至可读的。





你知道二进制数据是什么吗?你想如何存储它?

The problem is converting it to a string requires a little more knowledge: specifically the format of the data you are reading and the format you want to use as a string. Bytes are 8 bit hex values, but strings are made of characters - which are 16 bit Unicode values for the most part, and it may not just be a case of "read bytes, treat as characters" - the results you get as a string or text file may not be what you expect, or even readable.


Do you have any idea what the binary data is? And how you want to store it?


这篇关于如何读取文件作为Birary String vb.net的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆