I've got a method that streams files by returning a System.IO.FileStream pointing to a file opened for reading. What I want to do at this point is store the stream into a System.IO.MemoryStream as well.
The simplest option would be to first read the FileStream into the MemoryStream, and then return the MemoryStream to the caller. However this means that I'll have to buffer the entire file into memory before returning, thereby delaying the streaming response to the caller.
What I'd like to do (if possible) is read the FileStream into a MemoryStream and also stream it to the caller simultaneously. This way, the file doesn't have to be buffered before being returned, and still ends up getting stored into a MemoryStream.