I am receiving an HttpWebResponse containing both XML and a FileStream of unknown length. I know that streams can contain a very large amount of bytes, but the upper limits of strings are significantly smaller. Inside the XML I have a <size> tag that tells me how big the FileStream is.
Is it possible to get the information from the <size> prior to assigning the stream contents to a string? I want to prevent unhandled exceptions when I myXMLresponse=myStream.ReadToEnd, if the service sends me something bigger than it should.