How to convert a Stream to a String

  • Thread starter Thread starter ad
  • Start date Start date
What kind of stream? You should be able to use a StreamReader to get
the contents of the stream.
 
ad said:
I have a Steam, it read from a text file.
How can I convert this Stream to a String?

The easiest way is skip the stream and just do File.ReadAllText().

Alternatively, if you must use the stream, then do:

---8<---
new StreamReader(stream).ReadToEnd()
--->8---

-- Barry
 
Back
Top