What is the most efficient way to save a byte array as a file on disk in C#?

前端 未结 7 1159

Pretty simple scenario. I have a web service that receives a byte array that is to be saved as a particular file type on disk. What is the most efficient way to do this in C#?

7条回答
  •  别跟我提以往
    2021-02-06 20:36

    I had a similar problem dumping a 300 MB Byte array to a disk file...
    I used StreamWriter, and it took me a good 30 minutes to dump the file.
    Using FilePut took me arround 3-4 minutes, and when I used BinaryWriter, the file was dumped in 50-60 seconds.
    If you use BinaryWriter you will have a better performance.

提交回复
热议问题