Reputation: 43
I have a C# project name as ("Test") which has a class and a folder contains a html file and my senior has compile this project into a dll.
the content of the html file is = "Hello World"
the class contains :
string that read the whole html file. context.Respone.Write(the string above).
I have another web project which has a page to call the method above by adding the test dll. The question is, how can I read the content of the html file by getting it from the dll ? So that the web page can display "Hello World"
Upvotes: 3
Views: 6131
Reputation: 1054
Put your file in Embedded resource and read it using code liek that
public static string GetResourceFileContentAsString(string fileName)
{
var assembly = Assembly.GetExecutingAssembly();
var resourceName = "Your.Namespace." + fileName;
string resource = null;
using (Stream stream = assembly.GetManifestResourceStream(resourceName))
{
using (StreamReader reader = new StreamReader(stream))
{
resource = reader.ReadToEnd();
}
}
return resource;
}
Upvotes: 10