/*********************************************************************************
** IIS homedirctory在c:\inetpub\wwwroot **
** 虚拟目录在E:\WebApplication10. **
** 目前的程序在E:\WebApplication10\tmp文件夹下的一个页面. **
*********************************************************************************/
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
本文介绍了在IIS环境下,不同路径表达方式对应的绝对路径解析规则。通过实例展示如何使用Server.MapPath方法来获取当前目录及相对路径下的文件完整路径。
1万+

被折叠的 条评论
为什么被折叠?



