Ejemplo n.º 1
0
        /// <summary>
        /// 开始上传
        /// </summary>
        /// <param name="inputFile">HtmlInputFile对象</param>
        /// <param name="savePath">要保存的路径</param>
        /// <returns>文件名</returns>
        public string SaveFile(System.Web.UI.HtmlControls.HtmlInputFile inputFile, FileFolderKey fileFolderKey)
        {
            int state = 0;

            this.SetInputFileInfo(inputFile);
            return(this.Save(fileFolderKey.ToString(), string.Empty, ref state));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 开始上传
        /// </summary>
        /// <param name="inputFile">HtmlInputFile对象</param>
        /// <param name="savePath">要保存的路径</param>
        /// <param name="oldFileName">旧文件名称,便于删除(注:如果存在文件夹路径,程序将自动去除,只留下文件名)</param>
        /// <returns>文件名</returns>
        public string SaveFile(System.Web.UI.HtmlControls.HtmlInputFile inputFile, FileFolderKey fileFolderKey, string oldFileName)
        {
            int state = 0;

            oldFileName = this.ClearFileFolder(oldFileName);
            this.SetInputFileInfo(inputFile);
            return(this.Save(fileFolderKey.ToString(), oldFileName, ref state));
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 获取上传文件文件夹名   如果在web.Config文件中没找到相应信息  则默认存放到网站根目录的other文件夹
        /// </summary>
        /// <param name="fileFolderKey">指定存放的文件夹</param>
        /// <returns></returns>
        public static string GetFolder(FileFolderKey fileFolderKey)
        {
            string path = GetConfigString(fileFolderKey.ToString());

            if (path == null)
            {
                return("other");
            }
            return(path);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 删除指定文件
        /// </summary>
        /// <param name="fileFolderKey">文件夹名</param>
        /// <param name="fileName">文件名</param>
        /// <param name="delSmallPic">是否删除小图</param>
        public void Delete(FileFolderKey fileFolderKey, string fileName, bool delSmallPic)
        {
            string folder = GetConfigString(fileFolderKey.ToString());

            folder = folder == null ? "other" : folder;//没有找到则默认为other文件夹
            string delPath = string.Format("{0}/{1}", folder, this._bigChildPath);

            this.Del(delPath, fileName);
            if (delSmallPic)
            {
                delPath = string.Format("{0}/{1}", folder, this._smallChildPath);
                this.Del(delPath, fileName);//删除小图
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// 删除指定文件夹中所有文件
        /// </summary>
        /// <param name="directoryPath"></param>
        public void DeleteByDirectory(FileFolderKey fileFolderKey, string directoryPath)
        {
            string folder = GetConfigString(fileFolderKey.ToString());

            directoryPath = string.Format("{0}/{1}/{2}", this.Path, folder, directoryPath);
            if (Directory.Exists(directoryPath))
            {
                DirectoryInfo dir = Directory.CreateDirectory(directoryPath);
                foreach (FileInfo fileInfo in dir.GetFiles())
                {
                    fileInfo.Delete();
                }
                dir.Delete(false);
            }
        }
Ejemplo n.º 6
0
 /// <summary>
 /// 删除指定文件夹中所有文件
 /// </summary>
 /// <param name="directoryPath"></param>
 public void DeleteByDirectory(FileFolderKey fileFolderKey, string directoryPath)
 {
     string folder = GetConfigString(fileFolderKey.ToString());
     directoryPath = string.Format("{0}/{1}/{2}", this.Path, folder, directoryPath);
     if (Directory.Exists(directoryPath))
     {
         DirectoryInfo dir = Directory.CreateDirectory(directoryPath);
         foreach (FileInfo fileInfo in dir.GetFiles())
         {
             fileInfo.Delete();
         }
         dir.Delete(false);
     }
 }
Ejemplo n.º 7
0
 /// <summary>
 /// 获取上传文件文件夹名   如果在web.Config文件中没找到相应信息  则默认存放到网站根目录的other文件夹
 /// </summary>
 /// <param name="fileFolderKey">指定存放的文件夹</param>
 /// <returns></returns>
 public static string GetFolder(FileFolderKey fileFolderKey)
 {
     string path = GetConfigString(fileFolderKey.ToString());
     if (path == null) { return "other"; }
     return path;
 }
Ejemplo n.º 8
0
        /// <summary>
        /// 删除指定文件
        /// </summary>
        /// <param name="fileFolderKey">文件夹名</param>
        /// <param name="childFolderName">子文件夹路径</param>
        /// <param name="fileName">文件名</param>
        /// <param name="delSmallPic">是否删除小图</param>
        public void Delete(FileFolderKey fileFolderKey, string childFolderName, string fileName, bool delSmallPic)
        {
            string folder = GetConfigString(fileFolderKey.ToString());
            folder = folder == null ? "other" : folder;//没有找到则默认为other文件夹
            folder = string.Format("{0}/{1}", folder, childFolderName);//添加上子文件夹
            string delPath = string.Format("{0}/{1}", folder, this._bigChildPath);
            this.Del(delPath, fileName);
            if (delSmallPic)
            {
                delPath = string.Format("{0}/{1}", folder, this._smallChildPath);
                this.Del(delPath, fileName);//删除小图
            }

        }
Ejemplo n.º 9
0
 /// <summary>
 /// 开始上传
 /// </summary>
 /// <param name="inputFile">HtmlInputFile对象</param>
 /// <param name="savePath">要保存的路径</param>
 /// <param name="oldFileName">旧文件名称,便于删除(注:如果存在文件夹路径,程序将自动去除,只留下文件名)</param>
 /// <param name="state">上传状态.  0:上传成功.  1:没有选择要上传的文件.  2:上传文件类型不符.   3:上传文件过大  -1:应用程序错误.</param>
 /// <returns>文件名</returns>
 public string SaveFile(System.Web.UI.HtmlControls.HtmlInputFile inputFile, FileFolderKey fileFolderKey, string oldFileName, ref int state)
 {
     oldFileName = this.ClearFileFolder(oldFileName);
     this.SetInputFileInfo(inputFile);
     return this.Save(fileFolderKey.ToString(), oldFileName, ref state);
 }
Ejemplo n.º 10
0
 /// <summary>
 /// 开始上传
 /// </summary>
 /// <param name="inputFile">HtmlInputFile对象</param>
 /// <param name="savePath">要保存的路径</param>
 /// <param name="state">上传状态.  0:上传成功.  1:没有选择要上传的文件.  2:上传文件类型不符.   3:上传文件过大  -1:应用程序错误.</param>
 /// <returns>文件名</returns>
 public string SaveFile(System.Web.UI.HtmlControls.HtmlInputFile inputFile, FileFolderKey fileFolderKey, ref int state)
 {
     this.SetInputFileInfo(inputFile);
     return this.Save(fileFolderKey.ToString(), string.Empty, ref state);
 }