Server.MapPath(path)
       The MapPath method maps the specified relative or virtual path to the corresponding physical directory on the server.
Parameters (MSDN:ms-help://MS.MSDNQTR.2003FEB.2052/iisref/htm/ref_vbom_serommp.htm)
用法:
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的某一节点的属性值

    public void write()
        {
            string key1 = this.TextBox1.Text;
            DataSet ds = new DataSet();
            ds.ReadXml(Server.MapPath("")+"/web.config");
            // 不是Tables[0]
            ds.Tables[1].Rows[0][1] = key1;
            ds.AcceptChanges();
            ds.WriteXml(Server.MapPath("")+"/web.config");
            ds.Dispose();
            
        }

转载于:https://www.cnblogs.com/lanshh/archive/2006/06/29/438826.html

Server.MapPath() 探究相关推荐

  1. asp.net .ashx文件使用server.mappath解决方法

    本人试过多种方法,均不可用,最后灵光一动,为何不能人引用的命名空间入手了,以下是解决方法,经本人验证. System.Web.HttpContext.Current.Server.MapPath 给同 ...

  2. server.mapPath(.mdb)

    server.mapPath(".mdb") 用http://www.google.com搜索server.mapPath(".mdb"),可以得到很多采用ac ...

  3. Server.MapPath(path)的使用

    用法: 1.Server.MapPath("/") 应用程序根目录所在的位置 如 C:\Inetpub\wwwroot\ 2.Server.MapPath("./&quo ...

  4. Server.MapPath()目录详解

    最近在做相关的开发,碰到了Server.MapPath(),顺便来温习一下 Server.MapPath()获取网站的目录详解  ./当前目录 /网站主目录 ../上层目录 ~/网站虚拟目录 如果当前 ...

  5. ASP.NET中Request.ApplicationPath、Request.FilePath、Request.Path、.Request.MapPath、Server.MapPath的区别...

    1.Request.ApplicationPath->当前应用的目录    Jsp中, ApplicationPath指的是当前的application(应用程序)的目录,ASP.NET中也是这 ...

  6. Server.MapPath()的用法

    http://blog.csdn.net/qiuhaifeng_csu/article/details/19416407 Server.MapPath(string path)作用是返回与Web服务器 ...

  7. 引用到网站绝对路径Server.MapPath(~/myfile.mdb)

    在任何路径下,都可以用Server.MapPath("~/")引用到网站根目录下 转载于:https://www.cnblogs.com/yurichou/archive/2005 ...

  8. ASP.NET中Request.ApplicationPath、Request.FilePath、Request.Path、.Request.MapPath、Server.MapPath的区别

    ASP.NET中Request.ApplicationPath.Request.FilePath.Request.Path..Request.MapPath.Server.MapPath的区别 1.R ...

  9. ASP.NET中Server.MapPath() 和Request.MapPath()使用

    一. ASP.NET中Server.MapPath() 和 Request.MapPath()使用区别: Server.MapPath(string)  :是将相对于当前调用文件的文件(或目录)映射为 ...

最新文章

  1. 【iOS】iOS10.3新增API:应用内评分
  2. 设计模式-原型模式(Prototype)
  3. Tomcat 的运行机制
  4. 玻璃体混浊不要转眼球
  5. 【转】itk、vtk、qt 显示dicom 数据
  6. 【R】语言第五课----画图
  7. ThingJS平台制作第一人称视角下的巡更效果
  8. 【干货】微信小程序如何设置背景图片
  9. javascript作用域链详解
  10. apache roller_Apache Roller RC支持Java EE 6服务器,Alex Ruiz离开了Oracle
  11. 【Linux】Linux基础常用命令1(常用Linux命令的基本使用,Linux终端命令格式)
  12. 职场动物进化手册-读后感
  13. 开源GIS与空间数据库实战教程
  14. The requested URL *** was not found on this server
  15. 未来科技蒲公英大飞_大烟草的下跌告诉我们关于大科技的未来
  16. Splunk健康检查orphaned searches
  17. 自己动手搭建网站:域名和云服务器选购
  18. loadrunner 操作mysql_loadrunner学习笔记(从MYSQL中取数据)
  19. Jenkins在搭建过程中遇到的一些问题
  20. 什么叫数字化服务-数字化转型网

热门文章

  1. c+const_如何在C ++中使用const? 初学者指南
  2. sql 新建表 alter_SQL ALTER表
  3. 如何在Java中获取系统属性?
  4. node js 非阻塞io_Node Express JS:套接字IO模块示例
  5. scala 提取器模式匹配_Scala提取器应用,取消应用和模式匹配
  6. action中的动态方法调用
  7. 开课吧Java课堂:多线程如何同步?消息如何传递?
  8. Android-动画-view 动画笔记
  9. Java语言中几个常用的包
  10. 解决tex中参考文献出现[S.l.: s.n.]、[S.l.]、 [s.n.]问题