asp.net中文件的路径

本文介绍了在IIS环境下,不同路径表达方式对应的绝对路径解析规则。通过实例展示如何使用Server.MapPath方法来获取当前目录及相对路径下的文件完整路径。

/*********************************************************************************
   **  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

转载于:https://www.cnblogs.com/Elong/archive/2005/06/20/177771.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值