public OpResult SaveFile(string folderPath, HttpPostedFile file, bool overWrite)
        {
            if (file == null)
            {
                throw new ArgumentNullException("file");
            }

            if (!permission.IsExtAllowed(Path.GetExtension(file.FileName)))
            {
                return(OpResult.FileTypeNotAllowed);
            }

            if (file.ContentLength > permission.MaxSizePerFile)
            {
                return(OpResult.FileSizeLimitExceed);
            }

            if (CountAllFiles() >= permission.MaxFiles)
            {
                return(OpResult.FileLimitExceed);
            }

            if (GetTotalSize() + file.ContentLength >= permission.Quota)
            {
                return(OpResult.QuotaExceed);
            }

            string fileName = Path.GetFileName(file.FileName).ToCleanFileName(WebConfigSettings.ForceLowerCaseForUploadedFiles);

            string fullPath = GetPath(folderPath, fileName);

            if (!Directory.Exists(Path.GetDirectoryName(fullPath)))
            {
                return(OpResult.FolderNotFound);
            }

            if (File.Exists(fullPath))
            {
                if (overWrite)
                {
                    File.Delete(fullPath);
                }
                else
                {
                    return(OpResult.AlreadyExist);
                }
            }

            file.SaveAs(fullPath);
            return(OpResult.Succeed);
        }