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 / C++ / MFC
  4. hi how to find no of files in a folder

hi how to find no of files in a folder

Scheduled Pinned Locked Moved C / C++ / MFC
delphitutorial
7 Posts 5 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.
  • C Offline
    C Offline
    chethu665
    wrote on last edited by
    #1

    hi how to find out no of files in a folder of same extension and also i need names of it.i have the path and the extension name . if any one know abt it plz reply:-D

    "Men never do evil so completely and cheerfully as when they do it from religious conviction" -Pascal

    _ S A 4 Replies Last reply
    0
    • C chethu665

      hi how to find out no of files in a folder of same extension and also i need names of it.i have the path and the extension name . if any one know abt it plz reply:-D

      "Men never do evil so completely and cheerfully as when they do it from religious conviction" -Pascal

      _ Offline
      _ Offline
      _AnsHUMAN_
      wrote on last edited by
      #2

      chethu665 wrote:

      find out no of files in a folder of same extension and also i need names of it

      Have a look at FindFirstFile(), FindNextFile() and WIN32_FIND_DATA

      Somethings seem HARD to do, until we know how to do them. ;-)_AnShUmAn_

      H 1 Reply Last reply
      0
      • C chethu665

        hi how to find out no of files in a folder of same extension and also i need names of it.i have the path and the extension name . if any one know abt it plz reply:-D

        "Men never do evil so completely and cheerfully as when they do it from religious conviction" -Pascal

        S Offline
        S Offline
        Sonny Aman
        wrote on last edited by
        #3

        int getFileCount() { int count = 0; CFileFind finder; BOOL bWorking = finder.FindFile("*.*"); while (bWorking) { bWorking = finder.FindNextFile(); count ++ } return count; }

        'life is like a ten speed bike,most of us having gears we ne never use' ... i want to try those.

        S 1 Reply Last reply
        0
        • S Sonny Aman

          int getFileCount() { int count = 0; CFileFind finder; BOOL bWorking = finder.FindFile("*.*"); while (bWorking) { bWorking = finder.FindNextFile(); count ++ } return count; }

          'life is like a ten speed bike,most of us having gears we ne never use' ... i want to try those.

          S Offline
          S Offline
          Sonny Aman
          wrote on last edited by
          #4

          Oops.. You also need the names.. modify the function to return also the names using finder.GetFileName(). You can pass a pointer to a string array as argument and store the names in that.:)

          'life is like a ten speed bike,most of us having gears we ne never use' ... i want to try those.

          1 Reply Last reply
          0
          • _ _AnsHUMAN_

            chethu665 wrote:

            find out no of files in a folder of same extension and also i need names of it

            Have a look at FindFirstFile(), FindNextFile() and WIN32_FIND_DATA

            Somethings seem HARD to do, until we know how to do them. ;-)_AnShUmAn_

            H Offline
            H Offline
            Hamid Taebi
            wrote on last edited by
            #5

            And in the end use of FindClose :)


            WhiteSky


            1 Reply Last reply
            0
            • C chethu665

              hi how to find out no of files in a folder of same extension and also i need names of it.i have the path and the extension name . if any one know abt it plz reply:-D

              "Men never do evil so completely and cheerfully as when they do it from religious conviction" -Pascal

              A Offline
              A Offline
              Abhijeet Rajput
              wrote on last edited by
              #6

              :)Hello Reply from Aman Sonny seems correct. You can get the number of file in the varible count used by Aman. To get the name of file excluding extention use finder.getFileTitle() method. Abhijeet

              1 Reply Last reply
              0
              • C chethu665

                hi how to find out no of files in a folder of same extension and also i need names of it.i have the path and the extension name . if any one know abt it plz reply:-D

                "Men never do evil so completely and cheerfully as when they do it from religious conviction" -Pascal

                A Offline
                A Offline
                Abhijeet Rajput
                wrote on last edited by
                #7

                ;)Hello, Here goes ur full solution. int count = 0; CFileFind finder; CStringArray l_caryFileNames; BOOL bWorking = finder.FindFile("*.*"); while (bWorking) { bWorking = finder.FindNextFile(); l_caryFileNames.Add(finder.GetFileTitle()); count ++; } Abhijeet -- modified at 6:41 Tuesday 19th December, 2006

                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