Пример #1
0
 /// <summary>
 /// 清除自定义规则
 /// </summary>
 /// <param name="rule"></param>
 public static void ClearRule(FileRule rule)
 {
     if (CustomRules.ContainsKey(rule.Type))
     {
         CustomRules.Remove(rule.Type);
     }
 }
Пример #2
0
        public static FileTypeEnum CheckFile(HttpPostedFileBase file, FileRule rule)
        {
            var          extension = Path.GetExtension(file.FileName).ToLower();
            var          size      = file.ContentLength;
            FileTypeEnum result    = FileTypeEnum.UnKnow;

            if (Regex.IsMatch(extension, rule.FileExtensions))
            {
                if (rule.Size > 0)
                {
                    if (rule.Size < size)
                    {
                        throw new AbhsException(ErrorCodeEnum.FileSizeOverFlow, AbhsErrorMsg.ConstFileSizeError);
                    }
                }
                result = rule.Type;
            }
            return(result);
        }
Пример #3
0
 /// <summary>
 /// 设置自定义规则
 /// </summary>
 /// <param name="rule"></param>
 public static void SetRule(FileRule rule)
 {
     CustomRules[rule.Type] = rule;
 }