Checking for valid image in VB.Net

  • Thread starter Thread starter Christopher Kurtis Koeber
  • Start date Start date
C

Christopher Kurtis Koeber

Dear All,
I am working on an imaging application in Visual Basic.Net and I want
the application to check and see if the image is valid that I am loading so
that my application will not crash when loading the image. For example, if
someone creates a file that is not an JPEG yet it has that extension, how
can I program the application so that it will detect this? Thank you very
much in advance for your time and attention in this matter.
Sincerely,
Christopher Koeber
 
Dim b As Bitmap
Try
b = Bitmap("c:\image.jpg")
Catch ex As Exception
MessageBox.Show("Error")
End Try



Igor Stanek
 
Dim b As Bitmap
Try
b = New Bitmap("c:\image.jpg")
Catch ex As Exception
MessageBox.Show("Error")
End Try
 
Thanks, a lot, works like a charm!

Christopher
Igor Stanek said:
Dim b As Bitmap
Try
b = Bitmap("c:\image.jpg")
Catch ex As Exception
MessageBox.Show("Error")
End Try



Igor Stanek
 
Back
Top