时间: 2021-07-31 作者:daque
前一段功夫写代码时常常遇到获得路途题目,老是发觉有点乱,所以就归纳了下,大师若有须要不妨参考
<!--[if !supportlists]-->1. <!--[endif]-->在.net中web开拓时
<!--[if !supportlists]-->(1) <!--[endif]-->~/在runat=server的控件中会机动被领会为request.applicationpath的值,是暂时运用步调的目次 如
<!--[if !vml]--><!--[endif]-->
~/usercommunity/index.aspx则对应为/henu.rcenter.internal/usercommunity
(2) ./表白暂时目次
(3)../表白上一层目次 如usercommunity文献夹下的文献中不妨以:../module/来考察module中的文献
2 获得暂时乞求页面包车型的士路途:request.filepath
3 获得名目下的文献路途:
string path=appdomain. currentdomain .setupinformation.applicationbase+文献夹+文献
如获得名目下的temp文献夹下文献的路途
<!--[if !vml]--><!--[endif]-->
不妨用:string savepath = appdomain.currentdomain.setupinformation.applicationbase + "temp" + @"\" + filename
4 server.mappath用法:
<!--[if !vml]--><!--[endif]-->
若在名目下content文献夹下的userinfomanager.aspx代码中写如次路途
this.temppath = server.mappath("uploadresourceimage\\");
则归来 d:\wxm\熟习\content\uploadresourceimage