⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 fileworkerbase.cs

📁 动易SiteFactory&#8482 网上商店系统1.0源代码
💻 CS
字号:
namespace PowerEasy.Controls.Editor
{
    using PowerEasy.Common;
    using PowerEasy.Components;
    using System;
    using System.Configuration;
    using System.IO;
    using System.Web;
    using System.Web.UI;

    public abstract class FileWorkerBase : Page
    {
        private const string DEFAULT_USER_FILES_PATH = "/UserFiles/";
        private string sUserFilesDirectory;
        private string sUserFilesPath;

        protected FileWorkerBase()
        {
        }

        protected string UserFilesDirectory
        {
            get
            {
                if (this.sUserFilesDirectory == null)
                {
                    this.sUserFilesDirectory = base.Server.MapPath(this.UserFilesPath);
                    if (!FileSystemObject.IsExist(this.sUserFilesDirectory, FsoMethod.Folder))
                    {
                        FileSystemObject.Create(this.sUserFilesDirectory, FsoMethod.Folder);
                    }
                }
                return this.sUserFilesDirectory;
            }
        }

        protected string UserFilesPath
        {
            get
            {
                if (this.sUserFilesPath == null)
                {
                    this.sUserFilesPath = (string) base.Application["PowerEasy:UserFilesPath"];
                    if ((this.sUserFilesPath == null) || (this.sUserFilesPath.Length == 0))
                    {
                        this.sUserFilesPath = (string) this.Session["PowerEasy:UserFilesPath"];
                        if ((this.sUserFilesPath == null) || (this.sUserFilesPath.Length == 0))
                        {
                            this.sUserFilesPath = ConfigurationManager.AppSettings["PowerEasy:UserFilesPath"];
                            if ((this.sUserFilesPath == null) || (this.sUserFilesPath.Length == 0))
                            {
                                this.sUserFilesPath = "/UserFiles/";
                            }
                            if ((this.sUserFilesPath == null) || (this.sUserFilesPath.Length == 0))
                            {
                                this.sUserFilesPath = base.Request.QueryString["ServerPath"];
                            }
                        }
                    }
                    if (!this.sUserFilesPath.EndsWith("/"))
                    {
                        this.sUserFilesPath = this.sUserFilesPath + "/";
                    }
                }
                HttpPostedFile file = base.Request.Files["NewFile"];
                this.sUserFilesPath = this.sUserFilesPath.Replace("{$FileType}", Path.GetExtension(file.FileName).ToLower().Replace(".", ""));
                this.sUserFilesPath = this.sUserFilesPath.Replace("{$Year}", DateTime.Now.Year.ToString());
                this.sUserFilesPath = this.sUserFilesPath.Replace("{$Month}", DateTime.Now.Month.ToString());
                this.sUserFilesPath = this.sUserFilesPath.Replace("{$Day}", DateTime.Now.Day.ToString());
                this.sUserFilesPath = this.sUserFilesPath.Replace("//", "/");
                if (base.Request.ApplicationPath.EndsWith("/"))
                {
                    return ("/" + SiteConfig.SiteOption.UploadDir + "/" + this.sUserFilesPath).Replace("//", "/");
                }
                return (base.Request.ApplicationPath + "/" + SiteConfig.SiteOption.UploadDir + this.sUserFilesPath);
            }
        }
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -