Skip to content

Instantly share code, notes, and snippets.

@zplume
Created March 25, 2021 10:27
using System.IO;
using System.Text;
public static class StreamExtensions
{
public static string ToEncodedString(this Stream stream, Encoding enc = null)
{
enc = enc ?? Encoding.UTF8;
byte[] bytes = new byte[stream.Length];
stream.Position = 0;
stream.Read(bytes, 0, (int)stream.Length);
string data = enc.GetString(bytes);
return data;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment