VB
An object-oriented programming language developed by Microsoft that is implemented on the .NET Framework. Previously known as Visual Basic .NET.
2,827 questions
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
The Visual Basic 2022 Image.FromFile method throws an OutOfMemoryException if the file does not have a valid image format.
Is there a way to determine in advance whether the candidate file has a "valid image format"?
At present I'm using a Try...Catch block, but would prefer an alternative.
The help file says "This type of OutOfMemoryException exception represents a catastrophic failure. If you choose to handle the exception, you should include a catch block that calls the Environment.FailFast method to terminate your app"
That's pretty drastic, would like to forestall it.