开发者

ASP.NET ~ Resolving

I have an asp.net application that has various text files it needs to load into a memory cache at start up. They are email body templates.

I have them as files in my project in Visual studio, (with File.ReadAllText) but when I try to load them it is looking in the development web server home directory rather than t开发者_JAVA技巧he application directory.

So I need to resolve ~ but I don't yet have an HttpRequest to do it with (since this is at application start up.) How can I get the absolute path of "~/StandardEmails/Sample.txt" during application startup?


Try HttpContext.Current.Server.MapPath("~/StandardEmails/Sample.txt").


HttpContext.Current.Request.MapPath("~/StandardEmails/Sample.txt");
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜