string[] sAllowedExt = new string[] { ".jpg", ".jpeg", ".gif", ".png",".pdf", ".docx", ".doc" }; (!sAllowedExt.Contains(file.FileName.Substring(file.FileName.IndexOf('.')).ToLower())) is not working . Please suggest something else.
i would use Path.GetExtension to determine if the extension of your file is valid.
string[] sAllowedExt = new string[] { ".jpg", ".jpeg", ".gif", ".png", ".pdf", ".docx", ".doc" }; string Extension = System.IO.Path.GetExtension(file.FileName); bool Result = sAllowedExt .Any(x => x.Equals(Extension, StringComparison.CurrentCultureIgnoreCase));
Path.GetExtension(path)