I have a FileStream, which consists of several files placed in one file, and I have a list of file lengths, in other words, I can easily calculate the position and length of all files. What I want to create is an Open method that accepts fileindex and returns a stream containing only this file. Currently, I have implemented this using a memory stream, but it forces me to copy the entire file (not the container, but the entire contained) into memory, and I do not want to do this. So, what I would like to do is create a class that implements a stream and takes another stream, an offset and length parameter, and then is available for reading and searching, only when you look for Seek (0), you should get the offset of the underlying stream. So, as an adapter class, I was wondering if this is possible, or even a good idea, or if someone has better ideas on how to solve this problem. I understand that if I do this as I just described, I need to make sure that access to the litter stream is synchronized and that all partial streams are opened, contains a private variable that tells them where they are in the stream, but this is likely should be tolerable, right? Has anyone done anything like this before? Or is there a simpel .NET class that I can use? Any help would be appreciated.
Oh, and sorry for the bad English, I forgot to install my browser in English, so the spelling check tells me that everything is wrong.
Alxandr
source share