/*********************************************************************************
** 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
本文解析了在不同相对路径设置下,Server.MapPath方法返回的实际物理路径。通过实例演示了如何使用此方法来获取应用程序中文件的具体位置。
1万+

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



