BinaryWrite vs WriteFile

What should I use to write a file in response? I see these two different options. The first option is to read the file in the stream, and then write the bytes to the browser using

Response.BinaryWrite(new bytes[5])

The next option is to simply write the file from the file system directly from Response.WriteFile. Any advantages / disadvantages with any approach?

Edit: Fixed typos

+5
source share
2 answers

Another consideration is a file that is written one or more times. If you often write this file, you can cache it, so it Response.BinaryWritemakes the most sense.

If you have this in memory, I would not write it to the file system or use it Response.WriteFile.

+4
source

Response.TransmitFile , asp.net 2.0.

Response.WriteFile , . TransmitFile " HTTP ."

+5

All Articles