I've got a question about navigating memory streams.
Memory stream properties aside (like making sure the stream can use seek etc...) if someone is storing variable or dynamic data in a stream, how can you retrieve that data? Like, for example if a user could store an image from their hard drive (for example) in a memory stream. and could add to that memory stream a caption to go with the image...how could someone retrieve only the image from the stream if we don't know how big the image is? It could be any number of bytes. I know you can use the Read method and seek to the start of the image data (which a programmer might know depending on how they organize the stream) but how do you know when to stop reading (the count parameter)? Do memory streams contain a "map" of some sort? or is it strictly a STREAM stream, and your SOL if you don't know the locations of the data in the stream?
I ask because I am encrypting (or trying to) a memory stream and then serializing it. But the memory stream contains a class instance as well as some string, integer and object data. The string, integer and object data I have a handle on size, the class instance not so much. I know where the class instance starts, but the size...not so sure of.