华域联盟 .Net asp.net 文件路径之获得虚拟目录的网站的根目录

asp.net 文件路径之获得虚拟目录的网站的根目录

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虚拟目录

本文由 华域联盟 原创撰写:华域联盟 » asp.net 文件路径之获得虚拟目录的网站的根目录

转载请保留出处和原文链接:https://www.cnhackhy.com/44246.htm

本文来自网络,不代表华域联盟立场,转载请注明出处。

作者: sterben

发表回复

联系我们

联系我们

2551209778

在线咨询: QQ交谈

邮箱: [email protected]

工作时间:周一至周五,9:00-17:30,节假日休息

关注微信
微信扫一扫关注我们

微信扫一扫关注我们

关注微博
返回顶部