string Server.MapPath(string path)
返回与Web服务器上的指定虚拟路径相对应的物理文件路径。

<%=Server.MapPath(Request.ServerVariables["PATH_INFO"])%><%= Server.MapPath("/")%>
<%= Server.MapPath("")%>
<%=Server.MapPath(".")%><%= Server.MapPath("../")%>
<%= Server.MapPath("..")%>以上的代码在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


解决方案 »

  1.   

    就是文件WebForm1.aspx 在服务器上的路径,比如说在d:\web\WebForm1.aspx
      

  2.   

    就是相对 路径的问题,用server.mapth()可以返回指定文件 在服务器上的 绝对路径。
      

  3.   

    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("~")。