W
William Barnes
Is there a built-in method available for determining if a file represents a
graphic image? I've tried using something like this:
public bool IsGraphics(FileInfo fi){
Image tempImage;
try{
tempImage = Image.FromFile(fi.FullName);
return true;
}
catch(OutOfMemoryException){
}
return false;
}
It works but there seems to be a lot of overhead with the exception handling
and all. For maximal flexibility now and in the future, I'd rather not base
it upon known graphics file extensions (.jpg, .gif, etc.). Does anyone know
of any .NET functionality that can do it better? I didn't see any static
methods in the Image class.
Thanks
William
graphic image? I've tried using something like this:
public bool IsGraphics(FileInfo fi){
Image tempImage;
try{
tempImage = Image.FromFile(fi.FullName);
return true;
}
catch(OutOfMemoryException){
}
return false;
}
It works but there seems to be a lot of overhead with the exception handling
and all. For maximal flexibility now and in the future, I'd rather not base
it upon known graphics file extensions (.jpg, .gif, etc.). Does anyone know
of any .NET functionality that can do it better? I didn't see any static
methods in the Image class.
Thanks
William