private static string StreamToString(Stream stream) { stream.Position = 0; using (var sr = new StreamReader(stream)) { return sr.ReadToEnd(); } }