日期:2011-10-01  浏览次数:20449 次

/############################################
版权声明:
文章内容为本站编辑,创作.你可以任意转载、发布、使用但请务必标明文章原始出处及本声明
http://www.opent.cn  作者:浪淘沙
############################################/

using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Drawing;
using System.IO;
using System.Drawing.Imaging;

namespace EC
{
    /// <summary>
    /// 上传类
    /// </summary>
    public class UploadObj
    {

        public UploadObj()
        {
            //
            // TODO: 在此处添加构造函数逻辑
            //
        }
        /// <summary>
        /// 允许文件上传的类型枚举
        /// </summary>
        public enum FileType
        {
           jpg,gif,bmp,png           
        }

        #region 取得文件后缀
        /// <summary>
        /// 取得文件后缀
        /// </summary>
        /// <param name="filename">文件名称</param>
        /// <returns></returns>
        public static string GetFileExtends(string filename)
        {
            string ext = null;
            if (filename.IndexOf('.') > 0)
            {
                string[] fs = filename.Split('.');
                ext = fs[fs.Length - 1];
            }
            return ext;
        }
        #endregion

        #region 检测文件是否合法
        /// <summary>
        /// 检测上传文件是否合法
        /// </summary>
        /// <param name="fileExtends">文件后缀名</param>
        /// <returns></returns>
        public static bool CheckFileExtends(string fileExtends)
        {
            bool status = false;
            fileExtends = fileExtends.ToLower();