ASP.NET 根路径的获取

xiaoxiao2022-06-12  32

ASP.NET 根路径的获取 private string _ApplicationPath;/// <summary>/// 虚拟应用程序根路径/// </summary>public string ApplicationPath{get{_ApplicationPath = HttpContext.Current.Request.ApplicationPath;if (_ApplicationPath.Length == 1){_Applicati;}return _ApplicationPath;}}private string _CurrentPath;/// <summary>/// 当前的绝对路径/// </summary>public string CurrentPath{get{_CurrentPath = HttpContext.Current.Server.MapPath(".").ToLower();//当前的绝对路径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;}} 获得全部的虚拟目录: Request.Url.AbsoluteUri.Replace(Request.Url.AbsolutePath, "") + Request.ApplicationPath
转载请注明原文地址: https://www.6miu.com/read-4933496.html

最新回复(0)