J Jon Skeet [C# MVP] Sep 30, 2005 #2 Paul said: How do I convert a System.IO.Stream to a string variable. Click to expand... Do you mean you want to read the contents of a stream, decoding it into a string, and storing the result in a variable? If so: using (StreamReader reader = new StreamReader(stream)) { string contents = reader.ReadToEnd(); } Note that the above assumes an encoding of UTF-8. If you want a different encoding, specify it in the StreamReader constructor.
Paul said: How do I convert a System.IO.Stream to a string variable. Click to expand... Do you mean you want to read the contents of a stream, decoding it into a string, and storing the result in a variable? If so: using (StreamReader reader = new StreamReader(stream)) { string contents = reader.ReadToEnd(); } Note that the above assumes an encoding of UTF-8. If you want a different encoding, specify it in the StreamReader constructor.