Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C#
  4. How to find all images in a directory...

How to find all images in a directory...

Scheduled Pinned Locked Moved C#
regextutorialquestion
5 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    SpiderMan
    wrote on last edited by
    #1

    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?

    J 1 Reply Last reply
    0
    • S SpiderMan

      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?

      J Offline
      J Offline
      Judah Gabriel Himango
      wrote on last edited by
      #2

      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

      S 1 Reply Last reply
      0
      • J Judah Gabriel 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

        S Offline
        S Offline
        SpiderMan
        wrote on last edited by
        #3

        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?

        J 1 Reply Last reply
        0
        • S SpiderMan

          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?

          J Offline
          J Offline
          Judah Gabriel Himango
          wrote on last edited by
          #4

          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

          U 1 Reply Last reply
          0
          • J Judah Gabriel 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

            U Offline
            U Offline
            User 1417132
            wrote on last edited by
            #5

            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.

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups