Last active
August 29, 2015 14:16
-
-
Save mishrsud/9d7069f706b8370d05e5 to your computer and use it in GitHub Desktop.
Gets an Embedded Resource (text) from currently executing assembly
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// <summary> | |
/// Reads text that is embedded into an assembly | |
/// </summary> | |
/// <remarks> | |
/// fullyQualifiedFileName is fully qualified, e.g. if the file abc.config was in assembly with namespace MyCompany.MyLib inside a | |
/// folder Config then fullyQualifiedFileName should read MyCompany.MyLib.abc.config | |
/// </remarks> | |
private static string GetTextFromEmbededResource(string fullyQualifiedFileName) | |
{ | |
var assembly = Assembly.GetExecutingAssembly(); | |
var result = string.Empty; | |
using (var stream = assembly.GetManifestResourceStream(fullyQualifiedFileName)) | |
{ | |
if (stream == null) return result; | |
var reader = new StreamReader(stream); | |
result = reader.ReadToEnd(); | |
} | |
return result; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment