mirror of
https://github.com/ckaczor/HomeMonitor.git
synced 2026-01-14 01:25:38 -05:00
19 lines
618 B
C#
19 lines
618 B
C#
using System.Reflection;
|
|
|
|
namespace ChrisKaczor.HomeMonitor.Environment.Service;
|
|
|
|
public static class ResourceReader
|
|
{
|
|
public static string GetString(string resourceName)
|
|
{
|
|
var assembly = Assembly.GetExecutingAssembly();
|
|
|
|
using var stream = assembly.GetManifestResourceStream(resourceName);
|
|
|
|
if (stream == null)
|
|
throw new Exception($"Resource {resourceName} not found in {assembly.FullName}. Valid resources are: {string.Join(", ", assembly.GetManifestResourceNames())}.");
|
|
|
|
using var reader = new StreamReader(stream);
|
|
return reader.ReadToEnd();
|
|
}
|
|
} |