For example, using Axarydax's answer: (so check docx mime)
List<String> wordMimeTypes = new List<String>(); wordMimeTypes.Add("application/msword"); wordMimeTypes.Add("application/doc"); wordMimeTypes.Add("appl/text"); wordMimeTypes.Add("application/vnd.msword"); wordMimeTypes.Add("application/vnd.ms-word"); wordMimeTypes.Add("application/winword"); wordMimeTypes.Add("application/word"); wordMimeTypes.Add("application/x-msw6"); wordMimeTypes.Add("application/x-msword"); //etc...etc... if (wordMimeTypes.Contains(file.ContentType)) { //word document } else { //not a word document }
More readable than regex, because regex will become a pain in the ass when trying to make an expression for a dozen mime types
source share