F
Fernando Rodríguez
Hi,
How can I read everything inside a Stream into a String or StringBuilder? O
TIA
How can I read everything inside a Stream into a String or StringBuilder? O

TIA
Fernando,
If you know the encoding for the stream, just wrap the stream in a
StreamReader, and call the ReadToEnd. Be careful if you are reading from a
network stream, as this will cause it to hang if the stream is not
disconnected when done (as opposed to reading messages from the stream and
keeping it open).
Does the Stream object represent just a character stream? In this case, you
can wrap it in a StreamReader and use its ReadToEnd method to read the whole
thing at once. This method returns a string.