using System.IO;
using System.Text;
using System.Threading.Tasks;
namespace Core.Util
{
public static partial class Extention
{
public static async Task<string> ReadToStringAsync(this Stream stream, Encoding encoding = null)
{
if (encoding == null)
encoding = Encoding.UTF8;
if (stream.CanSeek)
{
stream.Seek(0, SeekOrigin.Begin);
}
string resStr = string.Empty;
resStr = await new StreamReader(stream, encoding).ReadToEndAsync();
if (stream.CanSeek)
{
stream.Seek(0, SeekOrigin.Begin);
}
return resStr;
}
}
}