- private string _ApplicationPath;
- /// <summary>
- /// 虚拟应用程序根路径
- /// </summary>
- public string ApplicationPath
- {
- get
- {
- _ApplicationPath = HttpContext.Current.Request.ApplicationPath;
- if (_ApplicationPath.Length == 1)
- {
- _ApplicationPath = "";
- }
- return _ApplicationPath;
- }
- }
- private string _CurrentPath;
- /// <summary>
- /// 当前的绝对路径
- /// </summary>
- public string CurrentPath
- {
- get
- {
- _CurrentPath = HttpContext.Current.Server.MapPath(".").ToLower();//当前的绝对路径(这里MapPath里的"."代表当前服务器)
- if (_CurrentPath.Length == 1)
- {
- _CurrentPath = "";
- }
- return _CurrentPath;
- }
- }
- private string _RootPath;
- /// <summary>
- /// 系统的根目录
- /// </summary>
- public string RootPath
- {
- get
- {
- _RootPath = HttpContext.Current.Server.MapPath(HttpContext.Current.Request.ApplicationPath).ToLower();//当前的绝对路径
- if (_RootPath.Length == 1)
- {
- _RootPath = "";
- }
- return _RootPath;
- }
- }
ASP.NET 根路径的获取
最新推荐文章于 2019-09-28 10:56:37 发布