File Dialogs have a
Filter[
^] property that allows you to exclude any file types that you don't want. If you set it to only show files of image types (
bmp
,
jpg
, and
png
for example) then you can be fairly sure that the file path it returns won't cause problems when you load it using the
Image
class.
When loading a file using
Image.FromFile
or something equivalent it's always good to put a
try - catch
around the call just in case the image is valid. That should catch the case of trying to load an
Icon
(or something else) into an
Image
.