Created
March 25, 2021 10:27
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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