How to find all images in a directory...
-
As of right now, I'm using the FileInfo and DirectoryInfo classes to get all the files in a directory and then checking their file exentions to see if they match an image type (i.e ".jpg," ".bmp," etc). Is there a better way?
System.IO.Directory.GetFiles("c:\\windows", "*.jpg");
Tech, life, family, faith: Give me a visit. I'm currently blogging about: Horrific Minnesota Radio Judah Himango
-
System.IO.Directory.GetFiles("c:\\windows", "*.jpg");
Tech, life, family, faith: Give me a visit. I'm currently blogging about: Horrific Minnesota Radio Judah Himango
Thanks, I was doing something similar to this. I was wondering if there was a more generic way. For example, is there some way to match any image type without actually having to specify the extention for each one? Someone told me doing "*/images" would work. Has anyone tried this?
-
Thanks, I was doing something similar to this. I was wondering if there was a more generic way. For example, is there some way to match any image type without actually having to specify the extention for each one? Someone told me doing "*/images" would work. Has anyone tried this?
Haven't tried that, but AFAIK it won't work. There is a way to search for different extensions, something like Directory.GetFiles("c:\test", "*.jpg;*.png") or something. Search google or codeproject, I'm sure it's listed somewhere.
Tech, life, family, faith: Give me a visit. I'm currently blogging about: Horrific Minnesota Radio Judah Himango
-
Haven't tried that, but AFAIK it won't work. There is a way to search for different extensions, something like Directory.GetFiles("c:\test", "*.jpg;*.png") or something. Search google or codeproject, I'm sure it's listed somewhere.
Tech, life, family, faith: Give me a visit. I'm currently blogging about: Horrific Minnesota Radio Judah Himango
I don't think there is any way of identifying whether a file is an image file or not unless we know the datastructures used to save each type of the file. Images are just binary files. Graphic applications which support multiple image types know this. But such a component may not be available in the public domain. You may check GIMP project. But it will be a touch job.