/// <summary> /// Determines whether [is valid file type] [the specified file type]. /// </summary> /// <param name="control">The control.</param> /// <param name="fileType">Type of the file.</param> /// <returns></returns> /// <createdOn>1/26/2016 12:27 PM</createdOn> public static bool IsValidFileType(this FileUpload control, FileType fileType = FileType.Image) { if (!control.HasFile || !control.HasFiles) { throw new Exception("No file exsit in the file upload"); } var isAllowedExtension = false; if (control.AllowMultiple) { foreach (var file in control.PostedFiles) { isAllowedExtension = FileTypeSetting.IsAllowedExtension(file.FileName.GetSimpleFileExtension(), fileType); if (!isAllowedExtension) { return(false); } } } else { isAllowedExtension = FileTypeSetting.IsAllowedExtension(control.PostedFile.FileName.GetSimpleFileExtension(), fileType); } return(isAllowedExtension); }
public FileTypeOperation(Group parent, XmlElement element) : base(parent, element) { _types = new List <FileTypeSetting>(); TypeExtension = element.GetAttribute("typeExt"); TypeFriendlyName = element.GetAttribute("friendlyName"); TypeIcon = element.GetAttribute("icon"); FileTypeSetting setting = new FileTypeSetting() { TypeExt = TypeExtension, FriendlyName = TypeFriendlyName, Icon = TypeIcon }; _types.Add(setting); }