
Detecting if a filename is a valid picture file
You can quickly detect whether it is, in fact, an image file (but not that
it's not corrupted farther down) by examining the headers. For instance, a
bitmap file always starts with the two bytes &H4D42 ("BM") and a gif is
similar but I forget exactly. You can look up all sorts of file formats at
www.wotsit.org
Jim Deutch
MS Dev MVP
Quote:
>Hi-
> I'm using VB5 and I want a very fast way of determining if a given
>filename would cause problems if loaded into a standard Image control
>(i.e. that it's not a text file or .WAV file or a corrupted .JPG, etc).
>I have a sub that uses On Error and tries loading the file into a
>temporary Image control, but that method is too slow (although it works
>great). There may not be any other way.
>Thanks!
>Brad Stone
>The Salinon Corp.