Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/csharp-4.0/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何使用C#以特定格式写入二进制数据?_C#_C# 4.0_Binary Data_Binarywriter - Fatal编程技术网

如何使用C#以特定格式写入二进制数据?

如何使用C#以特定格式写入二进制数据?,c#,c#-4.0,binary-data,binarywriter,C#,C# 4.0,Binary Data,Binarywriter,我正在编写C#类以导出Seg-Y文件,用于教育目的。Seg-Y文件基本上是以预定义格式编写的文件,用于存储大块的二进制地震数据。在这些文件中,我们定义了标题中数字数据的格式(例如,IbmFloatingPoint4,TwosCompletementInteger4,TwosCompletementInteger2,FixedPointWithGain4,IeeeFloatingPoint4,等等),以便读者可以相应地读取文件。给定其中一种格式,如何确保数据被正确写入 现在我正在使用BinaryW

我正在编写C#类以导出Seg-Y文件,用于教育目的。Seg-Y文件基本上是以预定义格式编写的文件,用于存储大块的二进制地震数据。在这些文件中,我们定义了标题中数字数据的格式(例如,
IbmFloatingPoint4
TwosCompletementInteger4
TwosCompletementInteger2
FixedPointWithGain4
IeeeFloatingPoint4
,等等),以便读者可以相应地读取文件。给定其中一种格式,如何确保数据被正确写入

现在我正在使用
BinaryWriter.Write(Value)
在文件中写入数据,但我不确定写入数据使用的是哪种数字格式


感谢

该库支持读取这些格式,因此您可以查看这些格式的工作原理,并对其进行写入调整。

我仅使用未插拔的.Segy库来读取文件。在这个库中,他们使用Binaryreader类的默认方法,如ReadSingleIbm(对于IbmFloatingPoint4)、ReadInt32(对于TwosCompletementInteger4)、ReadInt16(对于TwosCompletementInteger2)等来读取特定数据,但是Binarywriter没有任何这样的方法。像IBMReadSingleIbm之类的东西不属于标准的
BinaryReader
类。看起来它们来自一个被引用的
pluggedimbits
库。对你来说,好消息是,这同时具有和。