Server.mappath用法

1.Server.MapPath ("/") 应用程序根目录所在的位置 如 C:\qq\qqroot\

2.Server.MapPath ("./") 表示所在页面的当前目录

注:等价于Server.MapPath ("") 返回 Server.MapPath ("")所在页面的物理文件路径

3.Server.MapPath ("../")表示上一级目录

4.Server.MapPath ("~/")表示当前应用级程序的目录,如果是根目录,就是根目录,如果是虚拟目录,就是虚拟目录所在的位置

如:C:\qq\qqroot\Example\ 注:等效于Server.MapPath ("~")。

时间: 2024-08-10 14:39:28

Server.mappath用法的相关文章

asp于Server.MapPath用法

总是忘记Server.MapPath的用法,以下记录了,以后使用: 总注:Server.MapPath获得的路径都是server上的物理路径,也就是常说的绝对路径 1.Server.MapPath("/") 注:获得应用程序根文件夹所在的位置.如 C:\Inetpub\wwwroot\. 2.Server.MapPath("./") 注:获得所在页面的当前文件夹,等价于Server.MapPath(""). 3.Server.MapPath(&q

Server.MapPath()用法

Server.MapPath(string path)作用是返回与Web服务器上的指定虚拟路径相对应的物理文件路径.其参数path为Web 服务器的虚拟路径,返回结果是与path相对应的物理文件路径.但有时参数并非为虚拟路径,而是用户自定义的文件名. Server.MapPath()的全名是System.Web.HttpContext.Current.Server.MapPath().有时在程序调试时会提示"当前上下文中不存在名称"Server""错误,从而不支持函

Server.MapPath 的使用方法

用法: 1.Server.MapPath ("/") 应用程序根目录所在的位置 如 C:\Inetpub\wwwroot\ 2.Server.MapPath ("./") 表示所在页面的当前目录 注:等价于Server.MapPath ("") 返回 Server.MapPath ("")所在页面的物理文件路径 3.Server.MapPath ("../")表示上一级目录 4.Server.MapPath

Server.MapPath()

./当前目录/网站主目录../上层目录~/网站虚拟目录如果当前的网站目录为E:\wwwroot   应用程序虚拟目录为E:\wwwroot\company 浏览的页面路径为E:\wwwroot\company\news\show.asp在show.asp页面中使用Server.MapPath("./")   返回路径为:E:\wwwroot\company\newsServer.MapPath("/")    返回路径为:E:\wwwrootServer.MapPa

Server.MapPath查询路径那几件事

主要总结Server.MapPath 这个方法的使用以及使用的场景,不是什么时候都适合使用: 1.实现功能: Server.MapPath能够获取指定URL相对服务器的物理路径,在IIS服务端,能够根据文件名来获取该文件的物理路径: 2.存在命令空间: System.Web.HttpContext.Current.Server.MapPath 以及System.web.MVC.Control.Server.Mapth; 3.使用情况: 既然是System.Web.HttpContent 也及时表

asp中Server.MapPath的使用方法

老是忘记Server.MapPath的使用方法了,下面记录一下,以备后用: 总注:Server.MapPath获得的路径都是服务器上的物理路径,也就是常说的绝对路径 1.Server.MapPath("/") 注:获得应用程序根目录所在的位置,如 C:\Inetpub\wwwroot\. 2.Server.MapPath("./") 注:获得所在页面的当前目录,等价于Server.MapPath(""). 3.Server.MapPath(&qu

asp.net server.mappath使用

1.Server.MapPath("/") 应用程序根目录所在的位置 如 C:\Inetpub\wwwroot\ 2.Server.MapPath("./") 表示所在页面的当前目录 注:等价于Server.MapPath("") 返回 Server.MapPath("") 所在页面的物理文件路径 3.Server.MapPath("../")表示上一级目录 4.Server.MapPath("~

转:Server.MapPath相关

如果你从Page类继承的类中执行这条语句,才可以简单地使用 DataBase = Server.MapPath("data.mdb");否则写全命名空间:System.Web.HttpContext.Current.Server.MapPath(); 总注:Server.MapPath获得的路径都是服务器上的物理路径,也就是常说的绝对路径1.Server.MapPath("/")注:获得应用程序根目录所在的位置,如 C:\Inetpub\wwwroot\.2.Ser

runat server的用法

aspx运行时会被编译,其中没有runat server属性的html标签会被直接写入response,有runat server属性的html标签会转换成对应的HtmlControl子类加入到页面的控件集合中,按照一个控件的生命周期进行处理,这就是"运行在服务器上"的意思.一个最直接的表现就是,当你写一个id="abc"的div,如果有runat server属性,在你的aspx.cs文件中直接可以使用abc.XXX来操作这个对象,而没有runat server的