mirror of
https://github.com/AlexMacocian/SystemExtensions.git
synced 2026-07-15 22:29:28 +00:00
7222528eed
* Update dependencies Implement AsyncLazy Fix namespaces Fix CD pipeline * Fix code issues Fix Int64BitStruct test
26 lines
588 B
C#
26 lines
588 B
C#
using System.IO;
|
|
|
|
namespace System.Extensions
|
|
{
|
|
public static class BytesExtensions
|
|
{
|
|
public static byte[] ReadAllBytes(this Stream stream)
|
|
{
|
|
if (stream is null)
|
|
{
|
|
throw new ArgumentNullException(nameof(stream));
|
|
}
|
|
|
|
var buffer = new byte[256];
|
|
using var ms = new MemoryStream();
|
|
int read;
|
|
while ((read = stream.Read(buffer, 0, 256)) > 0)
|
|
{
|
|
ms.Write(buffer, 0, read);
|
|
}
|
|
|
|
return ms.ToArray();
|
|
}
|
|
}
|
|
}
|