代码改变世界

asp.net(c#)文件的路径表示方法

2009-04-20 13:30  12月  阅读(687)  评论(0编辑  收藏  举报

/*********************************************************************************
   **  IIS homedirctory在c:\inetpub\wwwroot         **
   **  虚拟目录在E:\WebApplication10.           **
   **  目前的程序在E:\WebApplication10\tmp文件夹下的一个页面.     **
   转自:http://www.cnblogs.com/Elong/archive/2005/06/20/177771.html
   *********************************************************************************/
   string str = Server.MapPath("~/languages.xml");
   //str=E:\WebApplication10\languages.xml

   string str1 = Server.MapPath("./languages.xml");
   //str1=E:\WebApplication10\tmp\languages.xml

   string str2 = Server.MapPath("../languages.xml");
   //str2=E:\WebApplication10\languages.xml


   string str3 = Server.MapPath("mm/languages.xml");
   //str3=E:\WebApplication10\tmp\mm\languages.xml

   string str4 = Server.MapPath("/mm/languages.xml");
   //str4=c:\inetpub\wwwroot\mm\languages.xml