C#访问服务器当前目录路径的表示方法

Context.Server.MapPath("/")    //返回应用程序根目录所在的位置 如 C:\Inetpub\wwwroot\


Context.Server.MapPath("~")  //表示当前应用级程序的目录,如果是根目录,就是根目录,如果是虚拟目录,就是虚拟目录所在的位置 如:C:\Inetpub\wwwroot\Example\  注:等效于Context.Server.MapPath("~")。

 

Context.Server.MapPath("./")   //返回当前目录绝对路径

 

Context.Server.MapPath("../")   //返回上一级目录的绝对路径

 

posted @ 2017-03-28 18:05  那一轮弯月~  阅读(3030)  评论(0编辑  收藏  举报