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 / C++ / MFC
  4. Getting content of a folder

Getting content of a folder

Scheduled Pinned Locked Moved C / C++ / MFC
question
11 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.
  • J Offline
    J Offline
    Jaran Nilsen
    wrote on last edited by
    #1

    I am looking for a solution for getting the content of a folder (files and / or folders). Does anyone know how I can do this?

    C C 2 Replies Last reply
    0
    • J Jaran Nilsen

      I am looking for a solution for getting the content of a folder (files and / or folders). Does anyone know how I can do this?

      C Offline
      C Offline
      Chris Losinger
      wrote on last edited by
      #2

      FindFIrstFile/FindNextFile or http://www.codeproject.com/file/sadirread.asp -c


      When history comes, it always takes you by surprise.

      Bobber!

      J 1 Reply Last reply
      0
      • C Chris Losinger

        FindFIrstFile/FindNextFile or http://www.codeproject.com/file/sadirread.asp -c


        When history comes, it always takes you by surprise.

        Bobber!

        J Offline
        J Offline
        Jaran Nilsen
        wrote on last edited by
        #3

        Thanks, I will look at the FindFirstFile/FindNextFile functions. I tried the class that you linked to, but it didn't seem like it would list the content of just the folder I selected, but all the other subdirectories, or nothing... Thanks again. -J

        C 1 Reply Last reply
        0
        • J Jaran Nilsen

          Thanks, I will look at the FindFirstFile/FindNextFile functions. I tried the class that you linked to, but it didn't seem like it would list the content of just the folder I selected, but all the other subdirectories, or nothing... Thanks again. -J

          C Offline
          C Offline
          Chris Losinger
          wrote on last edited by
          #4

          jaran wrote: it didn't seem like it would list the content of just the folder I selected, but all the other subdirectories, or nothing... it will certainly do a single folder. just set Recurse to false. -c


          When history comes, it always takes you by surprise.

          Bobber!

          J 1 Reply Last reply
          0
          • C Chris Losinger

            jaran wrote: it didn't seem like it would list the content of just the folder I selected, but all the other subdirectories, or nothing... it will certainly do a single folder. just set Recurse to false. -c


            When history comes, it always takes you by surprise.

            Bobber!

            J Offline
            J Offline
            Jaran Nilsen
            wrote on last edited by
            #5

            Ok, so this is what I try: CSADirRead dirReader; dirReader.Recurse() = false; dirReader.ClearDirs(); dirReader.GetDirs("D:\\Stash"); CSADirRead::SADirVector &directories = dirReader.Dirs(); //Temp var for folder name CString sFolder; OutputDebugString("Sub folders:\n"); for (CSADirRead::SADirVector::const_iterator dit = directories.begin(); dit!=directories.end(); dit++) { sFolder.Format("%s", (*dit).m_sName); OutputDebugString(sFolder+"\n"); sDirList = sDirList+"D"+sFolder+"|"; } Don't mind the OutputDebugString, and the other string formatting (sDirList). The problem is that the only thing that is returned is "D:\Stash", not the subfolders... Do you know why? What have I done wrong...? Thanks.

            C 1 Reply Last reply
            0
            • J Jaran Nilsen

              Ok, so this is what I try: CSADirRead dirReader; dirReader.Recurse() = false; dirReader.ClearDirs(); dirReader.GetDirs("D:\\Stash"); CSADirRead::SADirVector &directories = dirReader.Dirs(); //Temp var for folder name CString sFolder; OutputDebugString("Sub folders:\n"); for (CSADirRead::SADirVector::const_iterator dit = directories.begin(); dit!=directories.end(); dit++) { sFolder.Format("%s", (*dit).m_sName); OutputDebugString(sFolder+"\n"); sDirList = sDirList+"D"+sFolder+"|"; } Don't mind the OutputDebugString, and the other string formatting (sDirList). The problem is that the only thing that is returned is "D:\Stash", not the subfolders... Do you know why? What have I done wrong...? Thanks.

              C Offline
              C Offline
              Chris Losinger
              wrote on last edited by
              #6

              jaran wrote: The problem is that the only thing that is returned is "D:\Stash", not the subfolders ahh. yes, i see what you mean. the class doesn't provide a way to get a list of subfolders in a given folder. *edit* i have updated the class to support this functionality */edit* well, FindFirstFile/FindNextFile are easy enough to use. -c


              When history comes, it always takes you by surprise.

              Bobber!

              J 1 Reply Last reply
              0
              • C Chris Losinger

                jaran wrote: The problem is that the only thing that is returned is "D:\Stash", not the subfolders ahh. yes, i see what you mean. the class doesn't provide a way to get a list of subfolders in a given folder. *edit* i have updated the class to support this functionality */edit* well, FindFirstFile/FindNextFile are easy enough to use. -c


                When history comes, it always takes you by surprise.

                Bobber!

                J Offline
                J Offline
                Jaran Nilsen
                wrote on last edited by
                #7

                OK, well, then I'll make something out of FindFirstFile/FindNextFile. Thanks for your help. -Jaran

                1 Reply Last reply
                0
                • J Jaran Nilsen

                  I am looking for a solution for getting the content of a folder (files and / or folders). Does anyone know how I can do this?

                  C Offline
                  C Offline
                  Chintan
                  wrote on last edited by
                  #8

                  You can do it by using "CFindFile" class. C.R.Naik

                  J 2 Replies Last reply
                  0
                  • C Chintan

                    You can do it by using "CFindFile" class. C.R.Naik

                    J Offline
                    J Offline
                    Jaran Nilsen
                    wrote on last edited by
                    #9

                    Is that a MFC class, or something I can download here?

                    1 Reply Last reply
                    0
                    • C Chintan

                      You can do it by using "CFindFile" class. C.R.Naik

                      J Offline
                      J Offline
                      Jaran Nilsen
                      wrote on last edited by
                      #10

                      I found a CFileFind class... Is that the one you mean?

                      C 1 Reply Last reply
                      0
                      • J Jaran Nilsen

                        I found a CFileFind class... Is that the one you mean?

                        C Offline
                        C Offline
                        Chintan
                        wrote on last edited by
                        #11

                        Ya....you are on the right way. C.R.Naik

                        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