欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

c# 獲得當(dāng)前絕對(duì)路徑的方法(超簡單)

 更新時(shí)間:2018年01月19日 09:39:33   投稿:jingxian  
下面小編就為大家分享一篇c# 獲得當(dāng)前絕對(duì)路徑的方法(超簡單),具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過來看看吧

廢話不多說,直接上代碼

/// <summary>
    /// 獲得當(dāng)前絕對(duì)路徑
    /// </summary>
    /// <param name="strPath">指定的路徑</param>
    /// <returns>絕對(duì)路徑</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);
      }
    }

以上這篇c# 獲得當(dāng)前絕對(duì)路徑的方法(超簡單)就是小編分享給大家的全部內(nèi)容了,希望能給大家一個(gè)參考,也希望大家多多支持腳本之家。

相關(guān)文章

最新評(píng)論