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 can get all files from selected directory?

How can get all files from selected directory?

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.
  • L Offline
    L Offline
    Le rner
    wrote on last edited by
    #1

    Hi all, In my application for browse directory if i select any directory than i want all files are selected from this directory. But here is one problem if i select any directory than it select only those file those are persent on the selected directory path.it not select files those are present inside the folder of folder on the selected directory path. Please help me for this. Any help or suggestions are appriciated. If possible please explain with example. Thanks in advance.

    IN A DAY, WHEN YOU DON'T COME ACROSS ANY PROBLEMS - YOU CAN BE SURE THAT YOU ARE TRAVELLING IN A WRONG PATH

    _ H D 3 Replies Last reply
    0
    • L Le rner

      Hi all, In my application for browse directory if i select any directory than i want all files are selected from this directory. But here is one problem if i select any directory than it select only those file those are persent on the selected directory path.it not select files those are present inside the folder of folder on the selected directory path. Please help me for this. Any help or suggestions are appriciated. If possible please explain with example. Thanks in advance.

      IN A DAY, WHEN YOU DON'T COME ACROSS ANY PROBLEMS - YOU CAN BE SURE THAT YOU ARE TRAVELLING IN A WRONG PATH

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

      Don't know if there exists an API to directly achieve this. You can use FindFirstFile alongwith PathIsDirectory (if it is a directory get all the file names from it) and implement a recursive solution to get all the files from the parent as well as the child directories.

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

      1 Reply Last reply
      0
      • L Le rner

        Hi all, In my application for browse directory if i select any directory than i want all files are selected from this directory. But here is one problem if i select any directory than it select only those file those are persent on the selected directory path.it not select files those are present inside the folder of folder on the selected directory path. Please help me for this. Any help or suggestions are appriciated. If possible please explain with example. Thanks in advance.

        IN A DAY, WHEN YOU DON'T COME ACROSS ANY PROBLEMS - YOU CAN BE SURE THAT YOU ARE TRAVELLING IN A WRONG PATH

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

        Except FindFirstFile you can use of DlgDirList for get files and folders.

        _ 1 Reply Last reply
        0
        • H Hamid Taebi

          Except FindFirstFile you can use of DlgDirList for get files and folders.

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

          The DlgDirList function replaces the contents of a list box with the names of the subdirectories and files in a specified directory. so if the user does not have a list box at his disposal, this API won't be useful.

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

          1 Reply Last reply
          0
          • L Le rner

            Hi all, In my application for browse directory if i select any directory than i want all files are selected from this directory. But here is one problem if i select any directory than it select only those file those are persent on the selected directory path.it not select files those are present inside the folder of folder on the selected directory path. Please help me for this. Any help or suggestions are appriciated. If possible please explain with example. Thanks in advance.

            IN A DAY, WHEN YOU DON'T COME ACROSS ANY PROBLEMS - YOU CAN BE SURE THAT YOU ARE TRAVELLING IN A WRONG PATH

            D Offline
            D Offline
            Dan 0
            wrote on last edited by
            #5

            This function will return the directory contents in a vector of strings.

            std::vector< std::wstring > GetDirectoryList( const std::wstring &strDirectory )
            {
            std::vector< std::wstring > contents;
            WIN32_FIND_DATA data;
            HANDLE hFind = FindFirstFile( (strDirectory + L"\\*").c_str() , &data);

             if ( hFind != INVALID\_HANDLE\_VALUE ) {
                  do {
                       contents.push\_back( data.cFileName );
                  } while ( FindNextFile( hFind , &data ) != 0 );
                  FindClose( hFind );
             }
             return contents;
            

            }

            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