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. How to read folder recursively?

How to read folder recursively?

Scheduled Pinned Locked Moved C / C++ / MFC
helptutorialquestion
5 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.
  • B Offline
    B Offline
    baldha rakesh
    wrote on last edited by
    #1

    hi all, please help me on read recursive folder.

    Thanks & Regards rakesh baldha

    M T T 3 Replies Last reply
    0
    • B baldha rakesh

      hi all, please help me on read recursive folder.

      Thanks & Regards rakesh baldha

      M Offline
      M Offline
      Mila025
      wrote on last edited by
      #2

      Hi, You mean read folder content ? use FindFirstFile, FindNextFile and FindClose Listing the Files in a Directory[^] and it for every found folder (with attribute FILE_ATTRIBUTE_DIRECTORY) besides folders called '.' and '..'.

      ----------- Mila

      1 Reply Last reply
      0
      • B baldha rakesh

        hi all, please help me on read recursive folder.

        Thanks & Regards rakesh baldha

        T Offline
        T Offline
        toxcct
        wrote on last edited by
        #3

        use SADirRead[^]


        You don't know where to start ? ask a good friend

        [VisualCalc 3.0][Flags Beginner's Guide]

        1 Reply Last reply
        0
        • B baldha rakesh

          hi all, please help me on read recursive folder.

          Thanks & Regards rakesh baldha

          T Offline
          T Offline
          ThatsAlok
          wrote on last edited by
          #4

          baldha rakesh wrote:

          hi all, please help me on read recursive folder. Thanks & Regards rakesh baldha

          MSDN and google are your friend.. any way your example

          void Recurse(LPCTSTR pstr)
          {
          CFileFind finder;

          // build a string with wildcards
          CString strWildcard(pstr);
          strWildcard += _T("\\*.*");

          // start working for files
          BOOL bWorking = finder.FindFile(strWildcard);

          while (bWorking)
          {
          bWorking = finder.FindNextFile();

            // skip . and .. files; otherwise, we'd
            // recur infinitely!
          
            if (finder.IsDots())
               continue;
          
            // if it's a directory, recursively search it
          
            if (finder.IsDirectory())
            {
               CString str = finder.GetFilePath();
               cout << (LPCTSTR) str << endl;
               Recurse(str);
            }
          

          }

          finder.Close();
          }

          "Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow

          cheers, Alok Gupta VC Forum Q&A :- I/ IV Support CRY- Child Relief And You

          B 1 Reply Last reply
          0
          • T ThatsAlok

            baldha rakesh wrote:

            hi all, please help me on read recursive folder. Thanks & Regards rakesh baldha

            MSDN and google are your friend.. any way your example

            void Recurse(LPCTSTR pstr)
            {
            CFileFind finder;

            // build a string with wildcards
            CString strWildcard(pstr);
            strWildcard += _T("\\*.*");

            // start working for files
            BOOL bWorking = finder.FindFile(strWildcard);

            while (bWorking)
            {
            bWorking = finder.FindNextFile();

              // skip . and .. files; otherwise, we'd
              // recur infinitely!
            
              if (finder.IsDots())
                 continue;
            
              // if it's a directory, recursively search it
            
              if (finder.IsDirectory())
              {
                 CString str = finder.GetFilePath();
                 cout << (LPCTSTR) str << endl;
                 Recurse(str);
              }
            

            }

            finder.Close();
            }

            "Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow

            cheers, Alok Gupta VC Forum Q&A :- I/ IV Support CRY- Child Relief And You

            B Offline
            B Offline
            baldha rakesh
            wrote on last edited by
            #5

            Thank you everybody i have got your concept. and i have implemetnted it thanks rakesh baldha.

            Thanks & Regards rakesh baldha

            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