Image Validations in c#

  • Thread starter Thread starter Sala
  • Start date Start date
S

Sala

I have 5 attachement files and i have to check whether all
files are image files if anyone of a file is not an image file then i
have to display alert message on webform..
 
Hi Sala,

You can try to load them into a Bitmap object. If it succeeds, it is a
known image format.
 
Use Image.FromFile(filePath) in a try/catch block. If it throws an
exception, it is not a valid image file.

--
HTH,

Kevin Spencer
Microsoft MVP
Bit Player
http://unclechutney.blogspot.com

Where there's a Will, there's a William.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top