Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does HttpResponse.WriteFile Method parameter bool readIntoMemory do?

What does HttpResponse.WriteFile Method parameter bool readIntoMemory do?

The MSDN documentation is very unhelpful in this regard as I came across this method and wasn't exactly sure why I'd want to do this or not do this.

Note: should anyone respond with "well it reads the file into memory" with no further explanation will be downvoted.

like image 331
Chris Marisic Avatar asked Aug 17 '26 06:08

Chris Marisic


1 Answers

Russ is right about the behavior - the reason you would use it is to avoid keeping the file open/locked - especially since the client might be slow, or time out, it may be more preferable to make the memory tradeoff and buffer the file into memory, so this bool lets you skip having to ReadAllBytes into a buffer on your own and then write the resulting buffer.

like image 132
James Manning Avatar answered Aug 18 '26 19:08

James Manning



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!