(".") ("./") ("")  当前目录
/根目录
../上层目录(相对当前来说)


string Server.MapPath(string path)
返回与Web服务器上的指定虚拟路径相对应的物理文件路径。

<%=Server.MapPath(Request.ServerVariables["PATH_INFO"])%>    C:\Inetpub\wwwroot\EnglishClub\manage\WebForm1.aspx
<%= Server.MapPath("/")%>  C:\Inetpub\wwwroot\

<%= Server.MapPath("")%>  C:\Inetpub\wwwroot\EnglishClub\manage
<%=Server.MapPath(".")%>  C:\Inetpub\wwwroot\EnglishClub\manage

<%= Server.MapPath("../")%>  C:\Inetpub\wwwroot\EnglishClub\
<%= Server.MapPath("..")%>C:\Inetpub\wwwroot\EnglishClub  



用法:
1.Server.MapPath("/")  应用程序根目录所在的位置 如 C:\Inetpub\wwwroot\
2.Server.MapPath("./")  表示所在页面的当前目录 注:等价于Server.MapPath("")  Server.MapPath(".") 
3.Server.MapPath("../")表示上一级目录
4.Server.MapPath("~/")表示当前应用级程序的目录,如果是根目录,就是根目录,如果是虚拟目录,就是虚拟目录所在的位置 如:C:\Inetpub\wwwroot\Example\
注:等效于Server.MapPath("~")。

不知道是否正确,研究中......
另:以下几句等效
string filename=Server.MapPath("./") + @"\Web.config";
string filename=Server.MapPath("./") + "/Web.config";
string filename=Server.MapPath("") + @"\Web.config"

附一例子:修改web.config的某一节点的属性值

asp.net 路径问题    public void write()
        }

 

相关文章:

  • 2021-12-22
  • 2021-11-19
  • 2022-03-07
  • 2021-08-27
  • 2022-03-02
猜你喜欢
  • 2021-06-26
  • 2021-07-24
  • 2022-12-23
  • 2022-01-18
  • 2021-05-21
  • 2022-12-23
  • 2022-01-11
相关资源
相似解决方案