大雀软件园

首页 软件下载 安卓市场 苹果市场 电脑游戏 安卓游戏 文章资讯 驱动下载
技术开发 网页设计 图形图象 数据库 网络媒体 网络安全 站长CLUB 操作系统 媒体动画 安卓相关
当前位置: 首页 -> 技术开发 -> 其他相关 -> C#中获取路径的几种方法

C#中获取路径的几种方法

时间: 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 获得名目下的文献路途:

c#中获取路径的几种方法图1

string path=appdomain. currentdomain .setupinformation.applicationbase+文献夹+文献

如获得名目下的temp文献夹下文献的路途

<!--[if !vml]--><!--[endif]-->

不妨用:string savepath = appdomain.currentdomain.setupinformation.applicationbase + "temp" + @"\" + filename

c#中获取路径的几种方法图2

4 server.mappath用法:

<!--[if !vml]--><!--[endif]-->

c#中获取路径的几种方法图3

若在名目下content文献夹下的userinfomanager.aspx代码中写如次路途

this.temppath = server.mappath("uploadresourceimage\\");

则归来 d:\wxm\熟习\content\uploadresourceimage

热门阅览

最新排行

Copyright © 2019-2021 大雀软件园(www.daque.cn) All Rights Reserved.