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
  1. Home
  2. General Programming
  3. C#
  4. How to count imgae files in a folder

How to count imgae files in a folder

Scheduled Pinned Locked Moved C#
csharphelptutoriallounge
8 Posts 4 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.
  • L Offline
    L Offline
    Lost User
    wrote on last edited by
    #1

    I am writing a small program in C# that has to count the number of image files and the number of text files in a single folder and to come up with a seperate value for each type of file. The code has to be general enough to accomodate changes to the number of image or text files in a given folder depending upon the designated path. At present, my approach has been to specify the path via code such as @"C:\My Program\Folder"; Any help would be appreciated.

    L J A 3 Replies Last reply
    0
    • L Lost User

      I am writing a small program in C# that has to count the number of image files and the number of text files in a single folder and to come up with a seperate value for each type of file. The code has to be general enough to accomodate changes to the number of image or text files in a given folder depending upon the designated path. At present, my approach has been to specify the path via code such as @"C:\My Program\Folder"; Any help would be appreciated.

      L Offline
      L Offline
      led mike
      wrote on last edited by
      #2

      Read the first thread in the forum titled "How to get an answer to your question". Pay attention to item #2

      1 Reply Last reply
      0
      • L Lost User

        I am writing a small program in C# that has to count the number of image files and the number of text files in a single folder and to come up with a seperate value for each type of file. The code has to be general enough to accomodate changes to the number of image or text files in a given folder depending upon the designated path. At present, my approach has been to specify the path via code such as @"C:\My Program\Folder"; Any help would be appreciated.

        J Offline
        J Offline
        Jacky Yiu
        wrote on last edited by
        #3

        if you know the file type, the easiest way is use Directory.GetFiles(path, "*.ext"); it will return a string array, you can get the file count using Properties of Length

        L 1 Reply Last reply
        0
        • L Lost User

          I am writing a small program in C# that has to count the number of image files and the number of text files in a single folder and to come up with a seperate value for each type of file. The code has to be general enough to accomodate changes to the number of image or text files in a given folder depending upon the designated path. At present, my approach has been to specify the path via code such as @"C:\My Program\Folder"; Any help would be appreciated.

          A Offline
          A Offline
          Anthony Mushrow
          wrote on last edited by
          #4

          You can use DirectoryInfo to get all files in a specific folder, you can also get it to only return files with specific file extensions, so look up how to use directoryinfo, and start making a list of all the file extensions that your image files have.

          My current favourite word is: Waffle Cheese is still good though.

          L 1 Reply Last reply
          0
          • A Anthony Mushrow

            You can use DirectoryInfo to get all files in a specific folder, you can also get it to only return files with specific file extensions, so look up how to use directoryinfo, and start making a list of all the file extensions that your image files have.

            My current favourite word is: Waffle Cheese is still good though.

            L Offline
            L Offline
            Lost User
            wrote on last edited by
            #5

            Thank you so much. I'm gonna be all over this like a fat kid on candy.

            1 Reply Last reply
            0
            • J Jacky Yiu

              if you know the file type, the easiest way is use Directory.GetFiles(path, "*.ext"); it will return a string array, you can get the file count using Properties of Length

              L Offline
              L Offline
              Lost User
              wrote on last edited by
              #6

              Thank you so much. As I said before, I am on this like you can't believe.

              J 1 Reply Last reply
              0
              • L Lost User

                Thank you so much. As I said before, I am on this like you can't believe.

                J Offline
                J Offline
                Jacky Yiu
                wrote on last edited by
                #7

                Then you can use System.Drawing.Imaging.ImageCodecInfo.GetImageEncoders(); to get all supported image format, or you could create your own image format array to loop the extension as I mention(and what you did).

                L 1 Reply Last reply
                0
                • J Jacky Yiu

                  Then you can use System.Drawing.Imaging.ImageCodecInfo.GetImageEncoders(); to get all supported image format, or you could create your own image format array to loop the extension as I mention(and what you did).

                  L Offline
                  L Offline
                  Lost User
                  wrote on last edited by
                  #8

                  You people are great! I have solved much of the program's display requirements... thanks to all of your assistance and pointers.

                  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