Skip to content

Commit 405e6d8

Browse files
author
喻斌
committed
resolved #75
1 parent 94f07e0 commit 405e6d8

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/CatLib.Core/Support/Util/Extension/StreamExtension.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,14 @@ public static long AppendTo(this Stream source, Stream destination, byte[] buffe
6363
/// <returns>字符串</returns>
6464
public static string ToText(this Stream source, Encoding encoding = null, bool closed = true)
6565
{
66+
Guard.Requires<ArgumentNullException>(source != null);
6667
try
6768
{
69+
if (!source.CanRead)
70+
{
71+
throw new RuntimeException($"Can not read stream, {nameof(source.CanRead)} == false");
72+
}
73+
6874
encoding = encoding ?? Util.Encoding;
6975
var memoryStream = source as MemoryStream;
7076
if (memoryStream != null)

0 commit comments

Comments
 (0)