Analyze content away from structure in binary

Using C #, I need to read a packed binary created using FORTRAN. The file is stored in the "Unformatted Sequential" format, as described here (about halfway down in the "Unformatted Sequential Files" section):

http://www.tacc.utexas.edu/services/userguides/intel8/fc/f_ug1/pggfmsp.htm

As you can see from the URL, the file is organized into “chunks” of no more than 130 bytes in size and includes 2 bytes of length (inserted by the FORTRAN compiler) surrounding each fragment.

So, I need to find an effective way to parse the actual file payload outside the formatting inserted into the compiler.

As soon as I extract the actual payload from the file, I will need to parse it into different data types. This will be the next exercise.

My first thoughts are to split the whole file into an array of bytes using File.ReadAllBytes. Then just iterate over the bytes, skipping formatting and passing the actual data to the second byte array.

In the end, this second byte array should contain the actual contents of the file minus all the formatting that I would need to return to get what I needed.

Since I'm fairly new to C #, I thought there might be a better, more acceptable way to solve this problem.

Also, in case this is useful, these files can be quite large (say, 30 MB), although most will be much smaller ...

+5
2

- (, , , , ). .

, 4.0, , , ReadAllBytes.

ReadAllBytes MemoryMappedFile, "" , . , .

+1

, , System.IO.BinaryReader. FileStream, BinaryReader, , blob. , , , BinaryReader .

, BinaryReader, MemoryStream.

File.ReadAllBytes. FileStream , (, ) , .

0

All Articles