mirror of
https://github.com/BepInEx/BepInEx.git
synced 2026-11-19 13:17:07 +00:00
33 lines
672 B
C#
33 lines
672 B
C#
using System;
|
|
using System.IO;
|
|
using System.Reflection;
|
|
|
|
namespace BepInEx.Installer
|
|
{
|
|
internal static class EmbeddedResource
|
|
{
|
|
public static Stream GetStream(string resourceName)
|
|
{
|
|
Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(resourceName);
|
|
|
|
if (stream == null)
|
|
throw new ArgumentException("Unable to find resource", nameof(resourceName));
|
|
|
|
return stream;
|
|
}
|
|
|
|
public static byte[] GetBytes(string resourceName)
|
|
{
|
|
using (Stream stream = GetStream(resourceName))
|
|
{
|
|
int length = (int)stream.Length;
|
|
|
|
byte[] buffer = new byte[length];
|
|
|
|
stream.Read(buffer, 0, length);
|
|
|
|
return buffer;
|
|
}
|
|
}
|
|
}
|
|
} |