C# - How do I read and write a binary file?

前端 未结 4 1470
不知归路
不知归路 2020-12-11 02:39

How do I read a raw byte array from any file, and write that byte array back into a new file?

4条回答
  •  爱一瞬间的悲伤
    2020-12-11 03:12

    Do you know about TextReader and TextWriter, and their descendents StreamReader and StreamWriter? I think these will solve your problem because they handle encodings, BinaryReader does not know about encodings or even text, it is only concerned with bytes.

    How to read text from a file

    How to write text to a file

    This is an excellent intro to file IO and encodings.

提交回复
热议问题