Just Me,
You can just pass the memory stream to the constructor of the
StreamReader class, and then call the ReadToEnd method, like so:
public function GetStringFromStream(Stream stream)
{
// Create a stream reader.
using (StreamReader reader = new StreamReader(stream))
{
// Just read to the end.
return reader.ReadToEnd();
}
}
If you need to set the encoding for the content in the stream, you can
pass an Encoding instance to the StreamReader constructor.
Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
-
mv*@spam.guard.caspershouse.com
"Just Me" <Just
Me@Microsoft.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
Does anybody have some sample code of converting a MemoryStream into a
String? I am having trouble doing this simple thing because I am tired
and under pressure. A code snippet would surly help. Thank you.