Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /// <summary>
- /// Retrieves embedded resource as string.
- /// </summary>
- /// <param name="resourceName">Resource name (sans assembly name).</param>
- /// <returns>Embedded resource as string.</returns>
- /// <remarks>Resource should contain a BOM so that its encoding can be detected by StreamReader.</remarks>
- public static string GetEmbeddedResourceString(string resourceName)
- {
- var assembly = Assembly.GetExecutingAssembly();
- using (var streamReader = new StreamReader(
- assembly.GetManifestResourceStream(string.Format("{0}.{1}", assembly.GetName().Name, resourceName)),
- //Detecting encoding using BOM.
- true))
- {
- return streamReader.ReadToEnd();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement