【发布时间】:2009-03-08 17:17:58
【问题描述】:
我有问题!
我知道使用 Vb6 创建的二进制数据,我想使用 C# 读取所有信息。
我该怎么做?
我没有文件的数据结构!!!
感谢您的关注
【问题讨论】:
标签: c# vb6 file-io binary binary-data
我有问题!
我知道使用 Vb6 创建的二进制数据,我想使用 C# 读取所有信息。
我该怎么做?
我没有文件的数据结构!!!
感谢您的关注
【问题讨论】:
标签: c# vb6 file-io binary binary-data
如果你知道二进制流的结构,你可以使用BinaryReader 类:
using (Stream inputStream = new FileStream("test.bin", FileMode.Open, FileAccess.Read, FileShare.Read))
using (BinaryReader reader = new BinaryReader())
{
int value1 = reader.ReadInt32(); // read 32 bit integer
float value2 = reader.ReadSingle(); // read a single-precision 32-bit number
char[] value3 = reader.ReadChars(10); // read 10, 16-bit unicode characters
...
}
如果您不知道要阅读的结构,则需要进行一些艰难的猜测。
【讨论】: