Rearranged repo to make room for additional projects

This commit is contained in:
Cameron
2024-09-07 20:31:54 -05:00
parent 7479dbf8f8
commit 0082a6f219
50 changed files with 92 additions and 1 deletions

View File

@@ -0,0 +1,25 @@
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();
}
public static async Task<byte[]> ReadAllBytesAsync(this Stream instream)
{
if (instream is MemoryStream)
return ((MemoryStream)instream).ToArray();
using var memoryStream = new MemoryStream();
await instream.CopyToAsync(memoryStream);
return memoryStream.ToArray();
}
}