de2bd2f9
“wangming”
项目初始化
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
using NCC.Dependency;
using System.IO;
using System.Text;
namespace NCC.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();
}
}
}
}
|