Get File that was `copied to output directory` in a class library
In a class library, I have a file that is set to copy to output directory at NewFolder1/HTMLPage1.htm
.
I tried this:
var foo = File.ReadAllText("NewFolder1开发者_开发知识库/HTMLPage1.htm");
But the error is:
ould not find a part of the path 'C:\Program Files (x86)\Common Files\Microsoft Shared\DevServer\10.0\NewFolder1\HTMLPage1.htm'.
How do I read this file?
Use this:
var foo = File.ReadAllText(Server.MapPath("NewFolder1/HTMLPage1.htm"));
If you place the above code in an MVC controller action you can change Server to this.HttpContext.Server to work
精彩评论