我不能在C#类库中使用Server.MapPath吗?

时间:2019-04-18 04:26:58

标签: .net c#-4.0 server.mappath

我需要访问我的应用程序中〜/ Templates中的文件夹。我没有得到关于server.MapPath的建议。为什么这样?

此外,我尝试使用HostingEnvironment.MapPath和System.Web.HttpContext.Current.Server.MapPath。但是它返回null。有什么解决办法吗?

var path = System.Web.HttpContext.Current.Server.MapPath("~/Templates");

0 个答案:

没有答案