We are reading huge files in to memorystream and reusing them across mulitple locations in the code.
Just wondering if it is a better idea to get byte[] of files and store them in a hashtable for such a scenario. This way we could close the memorystream when we are done and just recreate one from hashtable when needed. Just wondering if there are any drawbacks with this method.
Thanks
N
We are reading huge files in to memorystream and reusing them across mulitple locations
Share
One advantage of using a
byte[]rather than aMemoryStreamis that theMemoryStreamhas more state – it has a cursor. In particular, two threads could easily read from the same byte array (copying the section they’re interested in etc) whereas if they tried to useStream.Readconcurrently, they may not get the expected results.The downside of both of these is that they’re mutable 🙁