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. Real time directory listing

Real time directory listing

Scheduled Pinned Locked Moved C / C++ / MFC
c++helpquestion
11 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.
  • K Offline
    K Offline
    KirkNarine
    wrote on last edited by
    #1

    I'm trying to generate a directory listing of all the files in a specific directory as files are sent to it. Files are sent to this directory on a regular basis and each file needs to be listed with it's date created attribute. I can't just check by name to see if the file already exist in the list because I'm also checking for duplicates. Can anyone help me at least with how a real-time search coding in C++ will look like? Thanks

    A D A H 4 Replies Last reply
    0
    • K KirkNarine

      I'm trying to generate a directory listing of all the files in a specific directory as files are sent to it. Files are sent to this directory on a regular basis and each file needs to be listed with it's date created attribute. I can't just check by name to see if the file already exist in the list because I'm also checking for duplicates. Can anyone help me at least with how a real-time search coding in C++ will look like? Thanks

      A Offline
      A Offline
      Anurag Gandhi
      wrote on last edited by
      #2

      Can you please clear out what exactly u want.

      Anurag Gandhi. http://www.softgandhi.co.nr

      K 1 Reply Last reply
      0
      • K KirkNarine

        I'm trying to generate a directory listing of all the files in a specific directory as files are sent to it. Files are sent to this directory on a regular basis and each file needs to be listed with it's date created attribute. I can't just check by name to see if the file already exist in the list because I'm also checking for duplicates. Can anyone help me at least with how a real-time search coding in C++ will look like? Thanks

        D Offline
        D Offline
        David Crow
        wrote on last edited by
        #3

        Monitor the folder using either ReadDirectoryChangesW() or FindFirstChangeNotification().


        "A good athlete is the result of a good and worthy opponent." - David Crow

        "To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne

        K 1 Reply Last reply
        0
        • K KirkNarine

          I'm trying to generate a directory listing of all the files in a specific directory as files are sent to it. Files are sent to this directory on a regular basis and each file needs to be listed with it's date created attribute. I can't just check by name to see if the file already exist in the list because I'm also checking for duplicates. Can anyone help me at least with how a real-time search coding in C++ will look like? Thanks

          A Offline
          A Offline
          Abhijeet Pathak
          wrote on last edited by
          #4

          SHChangeNotifyRegister() function can be used if you want to receive notifications when something in shell namespace is changed... (e.g. file/folder creation, deletion, rename etc..) take a look at http://www.codeproject.com/atl/shellfoldertree.asp, it may help you... http://vbnet.mvps.org/index.html?code/shell/shchangenotify.htm : this is a Visual Basic sample... it might help you... :)

          K 1 Reply Last reply
          0
          • A Anurag Gandhi

            Can you please clear out what exactly u want.

            Anurag Gandhi. http://www.softgandhi.co.nr

            K Offline
            K Offline
            KirkNarine
            wrote on last edited by
            #5

            I need to know how you will list the files in a directory as the files are added in C++

            1 Reply Last reply
            0
            • D David Crow

              Monitor the folder using either ReadDirectoryChangesW() or FindFirstChangeNotification().


              "A good athlete is the result of a good and worthy opponent." - David Crow

              "To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne

              K Offline
              K Offline
              KirkNarine
              wrote on last edited by
              #6

              What is the best way to list a directory in C++. I've heard of using boost libraries. Any suggestions or comments?

              D 1 Reply Last reply
              0
              • A Abhijeet Pathak

                SHChangeNotifyRegister() function can be used if you want to receive notifications when something in shell namespace is changed... (e.g. file/folder creation, deletion, rename etc..) take a look at http://www.codeproject.com/atl/shellfoldertree.asp, it may help you... http://vbnet.mvps.org/index.html?code/shell/shchangenotify.htm : this is a Visual Basic sample... it might help you... :)

                K Offline
                K Offline
                KirkNarine
                wrote on last edited by
                #7

                Any suggestion on listing a directory in C++. I've heard of boost libraries, any comments on it?

                A 1 Reply Last reply
                0
                • K KirkNarine

                  Any suggestion on listing a directory in C++. I've heard of boost libraries, any comments on it?

                  A Offline
                  A Offline
                  Abhijeet Pathak
                  wrote on last edited by
                  #8

                  Yes, the following article on CP shows how to use Boost libraries for directory listing: http://www.codeproject.com/useritems/find_file.asp and the following one shows how to do the same without using Boost libraries i.e. by using Win32 API functions like FindFirstFile() etc. http://www.codeproject.com/cpp/recursedir.asp And, I guess, the second method would be best, because it will eliminate dependencies on Boost libraries as it uses core API functions. :)

                  K 1 Reply Last reply
                  0
                  • K KirkNarine

                    What is the best way to list a directory in C++. I've heard of using boost libraries. Any suggestions or comments?

                    D Offline
                    D Offline
                    David Crow
                    wrote on last edited by
                    #9

                    KirkNarine wrote:

                    What is the best way...

                    I guess that all depends on your viewpoint (i.e., what's best for you may not be for others, and vice versa).

                    KirkNarine wrote:

                    I've heard of using boost libraries. Any suggestions or comments?

                    Technically, C++ has no knowledge of folders and other file-system related things. I'm not familar with Boost so any comments would be unjust. In any case, check out _findfirst() and _findnext().


                    "A good athlete is the result of a good and worthy opponent." - David Crow

                    "To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne

                    1 Reply Last reply
                    0
                    • A Abhijeet Pathak

                      Yes, the following article on CP shows how to use Boost libraries for directory listing: http://www.codeproject.com/useritems/find_file.asp and the following one shows how to do the same without using Boost libraries i.e. by using Win32 API functions like FindFirstFile() etc. http://www.codeproject.com/cpp/recursedir.asp And, I guess, the second method would be best, because it will eliminate dependencies on Boost libraries as it uses core API functions. :)

                      K Offline
                      K Offline
                      KirkNarine
                      wrote on last edited by
                      #10

                      Thanks, you've been a huge help. This is just what I needed

                      1 Reply Last reply
                      0
                      • K KirkNarine

                        I'm trying to generate a directory listing of all the files in a specific directory as files are sent to it. Files are sent to this directory on a regular basis and each file needs to be listed with it's date created attribute. I can't just check by name to see if the file already exist in the list because I'm also checking for duplicates. Can anyone help me at least with how a real-time search coding in C++ will look like? Thanks

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

                        See How to Receive Shell Change Notifications [^] if helpfuls.


                        WhiteSky


                        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