获取当前绝对路径的方法

xiaoxiao2022-06-12  76

public static string GetMapPath(string strPath) { if (HttpContext.Current != null) { return HttpContext.Current.Server.MapPath(strPath); } else //非web程序引用 { if (strPath.StartsWith(“~/“)) strPath = strPath.Substring(2); else if (strPath.StartsWith(“/“)) strPath = strPath.Substring(1); return System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, strPath); } } 注意:要引用System.Web命名空间
转载请注明原文地址: https://www.6miu.com/read-4933035.html

最新回复(0)