regular expression to check file content type is .doc or not?

Posted by Pandiya Chendur on Stack Overflow See other posts from Stack Overflow or by Pandiya Chendur
Published on 2010-04-15T10:21:02Z Indexed on 2010/04/15 10:23 UTC
Read the original article Hit count: 235

Filed under:
|

When i use a file upload i use to check file contenttype with regular expressions... For ex

private bool IsImage(HttpPostedFile file)
    {
        if (file != null && Regex.IsMatch(file.ContentType, "image/\\S+") &&
          file.ContentLength > 0)
        {
            return true;
        }
        return false;
    }

This returns my file is an image or not... How to check it is a word(.doc/.docx) document or not using c#...

© Stack Overflow or respective owner

Related posts about c#

Related posts about regex