3using System.Reflection;
32 public static byte[]
LoadResource(
string ResourceName, Assembly Assembly)
34 using (Stream f = Assembly.GetManifestResourceStream(ResourceName))
37 throw new ArgumentException(
"Resource not found: " + ResourceName, nameof(ResourceName));
39 if (f.Length >
int.MaxValue)
40 throw new ArgumentException(
"Resource size exceeds " +
int.MaxValue.ToString() +
" bytes.", nameof(ResourceName));
42 int Len = (int)f.Length;
43 byte[] Result =
new byte[Len];
44 f.ReadAll(Result, 0, Len);
69 using (Stream f = Assembly.GetManifestResourceStream(ResourceName))
72 throw new ArgumentException(
"Resource not found: " + ResourceName, nameof(ResourceName));
74 if (f.Length >
int.MaxValue)
75 throw new ArgumentException(
"Resource size exceeds " +
int.MaxValue.ToString() +
" bytes.", nameof(ResourceName));
77 int Len = (int)f.Length;
78 byte[] Result =
new byte[Len];
79 f.ReadAll(Result, 0, Len);
Static class managing loading of resources stored as embedded resources or in content files.
static string LoadResourceAsText(string ResourceName, Assembly Assembly)
Loads a text resource from an embedded resource.
static string LoadResourceAsText(string ResourceName)
Loads a text resource from an embedded resource.
static byte[] LoadResource(string ResourceName)
Loads a resource from an embedded resource.
static byte[] LoadResource(string ResourceName, Assembly Assembly)
Loads a resource from an embedded resource.
Static class managing binary representations of strings.
static string GetString(byte[] Data, int Offset, int Count, Encoding DefaultEncoding)
Gets a string from its binary representation, taking any Byte Order Mark (BOM) into account.
Static class that dynamically manages types and interfaces available in the runtime environment.
static Assembly GetAssemblyForResource(string ResourceName)
Gets the assembly corresponding to a given resource name.