I need to be able to read a file format that mixes binary and non-binary data. Assuming I know the input is good, what’s the best way to do this? As an example, let’s take a file that has a double as the first line, a newline (0x0D 0x0A) and then ten bytes of binary data afterward. I could, of course, calculate the position of the newline, then make a BinaryReader and seek to that position, but I keep thinking that there has to be a better way.
Share
You can use System.IO.BinaryReader. The problem with this though is you must know what type of data you are going to be reading before you call any of the Read methods.
And of course the same methods exist for writing in System.IO.BinaryWriter.