Advertisement
is_a_cdr

GetEmbeddedResourceString.cs

May 16th, 2012
315
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.83 KB | None | 0 0
  1.         /// <summary>
  2.         /// Retrieves embedded resource as string.
  3.         /// </summary>
  4.         /// <param name="resourceName">Resource name (sans assembly name).</param>
  5.         /// <returns>Embedded resource as string.</returns>
  6.         /// <remarks>Resource should contain a BOM so that its encoding can be detected by StreamReader.</remarks>
  7.         public static string GetEmbeddedResourceString(string resourceName)
  8.         {
  9.             var assembly = Assembly.GetExecutingAssembly();
  10.             using (var streamReader = new StreamReader(
  11.                 assembly.GetManifestResourceStream(string.Format("{0}.{1}", assembly.GetName().Name, resourceName)),
  12.                 //Detecting encoding using BOM.
  13.                 true))
  14.             {
  15.                 return streamReader.ReadToEnd();
  16.             }
  17.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement