Server.MapPath方法的应用方法

原文链接: http://www.cnblogs.com/Spirithero/archive/2010/10/17/1853877.html
老是忘记Server.MapPath的使用方法了,下面记录一下,以备后用: 总注:Server.MapPath获得的路径都是服务器上的物理路径,也就是常说的绝对路径 1、Server.MapPath("/") 注:获得应用程序根目录所在的位置,如 C:\Inetpub\wwwroot\。 2、Server.MapPath("./") 注:获得所在页面的当前目录,等价于Server.MapPath("")。 3、Server.MapPath("../") 注:获得所在页面的上级目录。 4、Server.MapPath("~/") 注:获得当前应用级程序的目录,如果是根目录,就是根目录,如果是虚拟目录,就是虚拟目录所在的位置,如C:\Inetpub\wwwroot\Example\。 在页面用可以用 Server.MathPath(); 在类库中可以用 HttpContext.Current.Server.MapPth();

转载于:https://www.cnblogs.com/Spirithero/archive/2010/10/17/1853877.html

猜你喜欢

转载自blog.csdn.net/weixin_30214509/article/details/95051935
今日推荐