我有一个用 C 语言编写的二进制文件,其中包含一长串数字。 首先,它随后包含 4 个 int(因此前 16 个字节是 4 个 int),然后它包含 double(我假设每 8 个字节一个新的 double)。
任何一点或其他任何地方都没有空格。现在我需要用 C# 读取数据,但到目前为止我尝试的所有方法都不起作用,有什么建议吗?
最佳答案
using (BinaryReader br = new BinaryReader(File.Open("file", FileMode.Open)))
{
int a = br.ReadInt32();
int b = br.ReadInt32();
int c = br.ReadInt32();
int d = br.ReadInt32();
double e = br.ReadDouble();
double f = br.ReadDouble();
...
}
关于c# - 在C#中读取用C格式化的文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11259864/