a12*_*773 106 c# intellisense server.mappath visual-studio
我必须做些什么来做Server.MapPath工作?
我有using System.Web;
还有什么?当我输入时Server,没有快速结果选项(智能)Server.
有帮助吗?
Dot*_*ser 273
你可以试试这个
System.Web.HttpContext.Current.Server.MapPath(path);
Run Code Online (Sandbox Code Playgroud)
或使用 HostingEnvironment.MapPath
System.Web.Hosting.HostingEnvironment.MapPath(path);
Run Code Online (Sandbox Code Playgroud)
Lea*_*ide 14
您的项目需要引用程序集System.Web.dll.服务器是类型的对象HttpServerUtility.例:
HttpContext.Current.Server.MapPath(path);
Run Code Online (Sandbox Code Playgroud)
小智 7
System.Web.HttpContext.Current.Server.MapPath("~/") 如果我们从线程调用它,则返回 null。
所以,尝试使用
System.Web.Hosting.HostingEnvironment.MapPath("~/")