Embedding file as resource in dll
* In Visual Studio file properties set Build Action as Embedded Resource
And then you can read a file using this code
private static string ReadResourceFile(string defaultNamespace, string fileName){var resource = string.Format("{0}.{1}", defaultNamespace, fileName);using (var stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(resource))
{using (var sr = new StreamReader(stream)){return sr.ReadToEnd();
}}}
Comments
Post a Comment