Beispiel #1
0
        private string GetPath(string relativeFilePath)
        {
            relativeFilePath = GetRelativeFilePath(relativeFilePath);
            var baseDirectory = ApplicationPath.Substring(0, ApplicationPath.Length - 1);
            var path          = Path.Combine(baseDirectory, relativeFilePath.Substring(1));

            return(path);
        }
Beispiel #2
0
        /// <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);
        }