In C# what is the best way to tell if a particular file is an image?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Most picture formats specify the file type in the first few bytes of the image. You can read in a few bytes and look for the correct headers.
File extensions technically don’t hold any important data about the image. It just helps the OS figure out what program to use to open it. (But, checking the extn is probably the easiest way, and usually correct.)