开发者

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜