Assuming your templates are built-in and should stay that way (which I think you can reconsider), here is a function that I wrote some time ago that I used many times when working with embedded files (mostly .sql files) . It converts the embedded resource to a string. Then you may need to write a template to disk.
public static string GetEmbeddedResourceText(string resourceName, Assembly resourceAssembly) { using (Stream stream = resourceAssembly.GetManifestResourceStream(resourceName)) { int streamLength = (int)stream.Length; byte[] data = new byte[streamLength]; stream.Read(data, 0, streamLength);
Usage example:
var text = GetEmbeddedResourceText("Namespace.ResourceFileName.txt", Assembly.GetExecutingAssembly());
Russell McClure
source share