/// <summary> /// 获取当前目录 /// (网站为网站根目录,测试时为dll所在目录) /// </summary> /// <param name="path"></param> /// <returns></returns> public static string GetMapPath(string path) { string contentRootPath = ApplicationPath.Substring(0, ApplicationPath.LastIndexOf("bin"));// AutofacHelper.GetScopeService<IHostingEnvironment>().ContentRootPath; if (!string.IsNullOrWhiteSpace(path)) { path = path.Replace("/", "\\"); if (!path.StartsWith("\\")) { path = "\\" + path; } path = path.Substring(path.IndexOf('\\') + (contentRootPath.EndsWith("\\") ? 1 : 0)); } return(contentRootPath + path); }