mirror of
https://github.com/Ikatono/ComiServ.git
synced 2025-10-28 20:45:35 -05:00
v1.0 release
This commit is contained in:
19
Extensions/StreamExtentions.cs
Normal file
19
Extensions/StreamExtentions.cs
Normal file
@@ -0,0 +1,19 @@
|
||||
namespace ComiServ.Extensions
|
||||
{
|
||||
public static class StreamExtensions
|
||||
{
|
||||
//https://stackoverflow.com/questions/1080442/how-do-i-convert-a-stream-into-a-byte-in-c
|
||||
//https://archive.ph/QUKys
|
||||
public static byte[] ReadAllBytes(this Stream instream)
|
||||
{
|
||||
if (instream is MemoryStream)
|
||||
return ((MemoryStream)instream).ToArray();
|
||||
|
||||
using (var memoryStream = new MemoryStream())
|
||||
{
|
||||
instream.CopyTo(memoryStream);
|
||||
return memoryStream.ToArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user