Esempio n. 1
0
        /// <summary>
        /// 获得当前绝对路径
        /// </summary>
        /// <param name="strPath">指定的路径</param>
        /// <returns>绝对路径</returns>
        public static string GetMapPath(string strPath)
        {
            if (strPath.IndexOf(":") == -1)
            {
                if (HttpContext.Current != null)
                {
                    return(HttpContext.Current.Server.MapPath(strPath));
                }
                else //非web程序引用
                {
                    strPath = strPath.Replace("\\", "/");

                    if (Utils2.LeftStr(strPath, 1) == "/")
                    {
                        strPath = strPath.Substring(1, strPath.Length - 1);
                    }

                    strPath = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, strPath);

                    return(strPath.Replace("\\", "/"));
                }
            }
            else
            {
                return(strPath);
            }
        }
Esempio n. 2
0
 /// <summary>
 /// 隐藏用户名,格式:a**b
 /// </summary>
 /// <param name="username"></param>
 /// <returns></returns>
 public static string HideUserName(string username)
 {
     if (!string.IsNullOrEmpty(username))
     {
         return(Utils2.LeftStr(username, 1) + "**" + Utils2.RightStr(username, 1));
     }
     else
     {
         return("");
     }
 }