添加项目文件。

This commit is contained in:
2023-03-13 15:00:34 +08:00
parent 42bf06ca3e
commit 1d73df3235
1205 changed files with 185078 additions and 0 deletions

View File

@@ -0,0 +1,27 @@
using JNPF.DependencyInjection;
using System.Text;
namespace JNPF.Common.Extension;
/// <summary>
/// Stream扩展方法.
/// </summary>
[SuppressSniffer]
public static class StreamExtensions
{
/// <summary>
/// 把<see cref="Stream"/>转换为<see cref="string"/>.
/// </summary>
public static string ToString2(this Stream stream, Encoding? encoding = null)
{
if (encoding == null)
{
encoding = Encoding.UTF8;
}
using (StreamReader reader = new StreamReader(stream, encoding))
{
return reader.ReadToEnd();
}
}
}