string Server.MapPath(string path)
返回与Web服务器上的指定虚拟路径相对应的物理文件路径。
Server.MapPath(Request.ServerVariables[“PATH_INFO”])
Server.MapPath(“/”)
Server.MapPath(“”)
Server.MapPath(“.”)
Server.MapPath(“../”)
Server.MapPath(“..”)
Page.Request.ApplicationPath
(HttpContext.Current.Request.PhysicalApplicationPath);
以上的代码在http://localhost/EnglishClub/manage/WebForm1.aspx页面
运行结果:
C:\Inetpub\wwwroot\EnglishClub\manage\WebForm1.aspx
C:\Inetpub\wwwroot\
C:\Inetpub\wwwroot\EnglishClub\manage
C:\Inetpub\wwwroot\EnglishClub\manage
C:\Inetpub\wwwroot\EnglishClub\
C:\Inetpub\wwwroot\EnglishClub
C:\Inetpub\wwwroot\EnglishClub\
由以上可以知道:
要想获得要是建立的虚拟目录的网站的根目录可以这样使用:
Server.MapPath(Page.Request.ApplicationPath)
您可能感兴趣的文章:
- apache中为php 设置虚拟目录
- 解析在apache里面给php写虚拟目录的详细方法
- Apache 添加虚拟目录注意事项
- Apache 虚拟目录和默认首页的设置
- php 在windows下配置虚拟目录的方法介绍
- Serv-U中虚拟目录的设置方法(文字+图文)
- asp.net Cookie跨域、虚拟目录等设置方法
- PHP编程之设置apache虚拟目录
声明:本站(华域联盟www.cnhackhy.com)所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。

评论(0)