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. Using CFileDialog to Set Current Directory

Using CFileDialog to Set Current Directory

Scheduled Pinned Locked Moved C / C++ / MFC
c++visual-studio
8 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.
  • A Offline
    A Offline
    Andy202
    wrote on last edited by
    #1

    I just want to set the current directory to the one navigated to by the user via the CFileDialog. MFC C++ Application VS 2005 on WIndows XP. I cannot seem to find an option other than to select a specific file. I need to open multi files when the user selects the directory, but this is not using the CFileDialog. Any suggestion please. Andy.

    _ D 2 Replies Last reply
    0
    • A Andy202

      I just want to set the current directory to the one navigated to by the user via the CFileDialog. MFC C++ Application VS 2005 on WIndows XP. I cannot seem to find an option other than to select a specific file. I need to open multi files when the user selects the directory, but this is not using the CFileDialog. Any suggestion please. Andy.

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

      you can set the current directory value in registry and then pick it up from there before showing the CFileDialog. In OPENFILENAME structure set lpstrInitialDir variable. Hope this helps you.

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

      A 1 Reply Last reply
      0
      • _ _AnsHUMAN_

        you can set the current directory value in registry and then pick it up from there before showing the CFileDialog. In OPENFILENAME structure set lpstrInitialDir variable. Hope this helps you.

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

        A Offline
        A Offline
        Andy202
        wrote on last edited by
        #3

        I wanted to use the CFileDialog to find the directory and then set it to the current directory.

        _ 1 Reply Last reply
        0
        • A Andy202

          I wanted to use the CFileDialog to find the directory and then set it to the current directory.

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

          Andy202 wrote:

          to find the directory

          which directory. the one that the user was currently in... Can you elaborate your problem?

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

          A 1 Reply Last reply
          0
          • _ _AnsHUMAN_

            Andy202 wrote:

            to find the directory

            which directory. the one that the user was currently in... Can you elaborate your problem?

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

            A Offline
            A Offline
            Andy202
            wrote on last edited by
            #5

            I just want to navigate to a directory and make that diectory the CurrentDirectory. Without selectin a file.

            1 Reply Last reply
            0
            • A Andy202

              I just want to set the current directory to the one navigated to by the user via the CFileDialog. MFC C++ Application VS 2005 on WIndows XP. I cannot seem to find an option other than to select a specific file. I need to open multi files when the user selects the directory, but this is not using the CFileDialog. Any suggestion please. Andy.

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

              You want to use CFileDialog to browse to a folder but not select a file? :confused: How about using SHBrowseForFolder() instead?

              "Love people and use things, not love things and use people." - Unknown

              "The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch

              A 1 Reply Last reply
              0
              • D David Crow

                You want to use CFileDialog to browse to a folder but not select a file? :confused: How about using SHBrowseForFolder() instead?

                "Love people and use things, not love things and use people." - Unknown

                "The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch

                A Offline
                A Offline
                Andy202
                wrote on last edited by
                #7

                Thanks, I used the SHBrowseForFolder. But needed to set the current directory for the CFileDialog - this was never shown - files opened in the background.

                CFileDialog dlg( !save, extension, NULL, OFN\_HIDEREADONLY | OFN\_OVERWRITEPROMPT, filter );
                // Set the current working directory
                dlg.m\_ofn.lpstrInitialDir = path;
                

                Many thanks, Andy.

                D 1 Reply Last reply
                0
                • A Andy202

                  Thanks, I used the SHBrowseForFolder. But needed to set the current directory for the CFileDialog - this was never shown - files opened in the background.

                  CFileDialog dlg( !save, extension, NULL, OFN\_HIDEREADONLY | OFN\_OVERWRITEPROMPT, filter );
                  // Set the current working directory
                  dlg.m\_ofn.lpstrInitialDir = path;
                  

                  Many thanks, Andy.

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

                  Just use the pidlRoot member of BROWSEINFO.

                  "Love people and use things, not love things and use people." - Unknown

                  "The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch

                  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