1.HttpContext.Current.Server.MapPath("~");2.HttpRuntime.AppDomainAppPath(推荐);3.AppDomain.CurrentDomain.BaseDirectory; 结果:E:\IIS\ ...
1.HttpContext.Current.Server.MapPath("~");
2.HttpRuntime.AppDomainAppPath(推荐);
3.AppDomain.CurrentDomain.BaseDirectory;
结果:
E:\get='_blank'>IIS\WebApi\
理由:
第1种写法,有时候HttpContext.Current会为null,比如多线程的时候。
第3种写法,有时候获得的路径是E:\IIS\WebApi,少了"\"。看其它博友说的,本人未验证。
原标题:[备忘录]三种方法取得网站根目录的物理路径
关键词:
*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们:
admin#shaoqun.com
(#换成@)。