I have an application on the Compact Framework that has some large embedded resources (some of them are several megabytes). I am calling assembly.GetManifestResourceStream(...)
which returns a Stream
object. However, I noticed that on some devices this call not only takes quite a while but causes the device to run out of available memory. Eventually I used reflector to look at the code for this method on the compact framework and it uses an internal method to get a byte[]
of the resource data. It then returns this data wrapped in a MemoryStream
.
Is there any way to retrieve a resource without using this call since it will always read everything into memory? Ideally I'd like to work with a Stream
that I can get random access to without having to read the whole thing into memory (similar to how a FileStream
works). It would be pretty neat if I could simply open a FileStream
on the assembly and start reading at the appropriate offset, but I doubt this is how resources are embedded.