Difference between a byte array and MemoryStream

后端 未结 2 1633
有刺的猬
有刺的猬 2021-02-04 03:39

I am reading a binary file into a parsing program. I will need to iterate through the file and look for certain markers so I can split the file up and pass those parts into the

相关标签:
2条回答
  • 2021-02-04 04:06

    A byte[] or MemoryStream will both require bringing the entire file into memory. A MemoryStream is really a wrapper around an underlying byte array. The best approach is to have two FileStream (one for input and one for output). Read from the input stream looking for the pattern used to indicate the file should be separated while writing to the current output file.

    You may want to consider wrapping the input and output files in a BinaryReader and BinaryWriter respectively if they add value to your scenario.

    0 讨论(0)
  • 2021-02-04 04:06

    A MemoryStream is basically a byte array with a stream interface, e.g. sequential reading/writing and the concept of a current position.

    0 讨论(0)
提交回复
热议问题