mirror of
https://github.com/bloxstraplabs/bloxstrap.git
synced 2025-04-21 10:01:27 -07:00
25 lines
720 B
C#
25 lines
720 B
C#
using System.Reflection;
|
|
|
|
namespace Bloxstrap
|
|
{
|
|
static class Resource
|
|
{
|
|
static readonly Assembly assembly = Assembly.GetExecutingAssembly();
|
|
static readonly string[] resourceNames = assembly.GetManifestResourceNames();
|
|
|
|
public static async Task<byte[]> Get(string name)
|
|
{
|
|
string path = resourceNames.Single(str => str.EndsWith(name));
|
|
|
|
using (Stream stream = assembly.GetManifestResourceStream(path)!)
|
|
{
|
|
using (MemoryStream memoryStream = new())
|
|
{
|
|
await stream.CopyToAsync(memoryStream);
|
|
return memoryStream.ToArray();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|