C# - Loads an embedded resource file of the calling assembly.

By , 10/5/2007
(1 ratings)
Loads an embedded resource file of the calling assembly.
/// <summary>
/// Loads an embedded resource file of the calling assembly.
/// </summary>
/// <param name="embeddedFileName">Filename to load, e.g. "data.xml"</param>
/// <returns>Stream to the embedded resource</returns>
public static Stream GetResourceStream(string embeddedFileName) {
    Stream stream = Assembly.GetCallingAssembly().GetManifestResourceStream(Assembly.GetCallingAssembly().GetName().Name + ".Resources." + embeddedFileName);
    return stream;
}

Comments

 

Log in, to comment!