CmsCommon/Commons.cs

(开头部分) 5KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

using System;
using System.Globalization;
using System.IO;
using System.Net;
using System.Text;
using System.Text.RegularExpressions;
using System.Web;
using System.Xml;

namespace Cms.Common
{
    public class Commons
    {
        #region  获取网站目录的物理路径

        /// <summary>
        /// 获取网站根目录的物理路径
        /// </summary>
        /// <returns>物理路径</returns>
        public static string GetMapPath()
        {
            string AppPath = "";

            HttpContext HttpCurrent = HttpContext.Current;

            if (HttpCurrent != null)
            {
                AppPath = HttpCurrent.Server.MapPath("~");
            }
            else //非web程序引用
            {
                AppPath = AppDomain.CurrentDomain.BaseDirectory;

                if (Regex.Match(AppPath, @"\\$", RegexOptions.Compiled).Success)
                {
                    AppPath = AppPath.Substring(0, AppPath.Length - 1);
                }
            }
            return AppPath;
        }

        /// <summary>
        /// 获取指定目录(或Url)的物理路径
        /// </summary>
        /// <param name="path">指定的路径</param>
        /// <returns>物理路径</returns>
        public static string GetMapPath(string path)
        {
            if (path.IndexOf("://") > -1)
            {
                return path;
            }

            if (HttpContext.Current != null)
            {
                return HttpContext.Current.Server.MapPath(path);
            }
            else //非web程序引用
            {
                path = path.Replace("/", "\\");
后面还有 136 行代码,购买后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明

AI 解读

登录后可用,每次 10 积分,解读结果公开显示在下面。

还没有人解读过这个文件。