zoukankan      html  css  js  c++  java
  • c# 如何获得当前绝对路径

            /// <summary>
            /// 获得当前绝对路径
            /// </summary>
            /// <param name="strPath">指定的路径</param>
            /// <returns>绝对路径</returns>
            public static string GetMapPath(string strPath)
            {
                if (strPath.ToLower().StartsWith("http://"))
                {
                    return strPath;
                }
                if (HttpContext.Current != null)
                {
                    string path = HttpContext.Current.Server.MapPath("~/" + strPath);
                    return path;
                }
                else //非web程序引用
                {
                    strPath = strPath.Replace("/", "\");
                    if (strPath.StartsWith("\"))
                    {
                        strPath = strPath.Substring(strPath.IndexOf('\', 1)).TrimStart('\');
                    }
                    return System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, strPath);
                }
            }
  • 相关阅读:
    Java 面试 --- 3
    Java 面试-- 1
    面试之痛 -- 二叉树 前序 中序 后序
    java 事务
    深入理解mybatis
    hibernate
    mybatis 原理
    spring 原理
    spring aop
    spring 事务
  • 原文地址:https://www.cnblogs.com/highest/p/8301376.html
Copyright © 2011-2022 走看看