public static string StreamToString(Stream stream)
{
stream.Position = 0;
using (StreamReader stremReader = new StreamReader(stream, Encoding.UTF8))
{
return stremReader.ReadToEnd();
}
} public static Stream StringToStream(string str)
{
byte[] strBytes = Encoding.UTF8.GetBytes(str);
return new MemoryStream(strBytes);
}