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 get current directory path in mfc??

How to get current directory path in mfc??

Scheduled Pinned Locked Moved C / C++ / MFC
c++tutorialquestion
6 Posts 5 Posters 1 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.
  • C Offline
    C Offline
    c
    wrote on last edited by
    #1

    thanx.... hussein

    B D I T C 5 Replies Last reply
    0
    • C c

      thanx.... hussein

      B Offline
      B Offline
      BlackDice
      wrote on last edited by
      #2

      Parse it from using GetModuleFileName() My articles www.stillwaterexpress.com BlackDice

      1 Reply Last reply
      0
      • C c

        thanx.... hussein

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

        The CWD is obtained with GetCurrentDirectory().


        "One must learn from the bite of the fire to leave it alone." - Native American Proverb

        1 Reply Last reply
        0
        • C c

          thanx.... hussein

          I Offline
          I Offline
          Ivan Cachicatari
          wrote on last edited by
          #4

          Try with this code:

          CFile file;
          if(file.Open(".",CFile::modeRead))
          {
          	 MessageBox(file.GetFilePath());
          }
          

          Ivan Cachicatari Blog[^] www.latindevelopers.com

          1 Reply Last reply
          0
          • C c

            thanx.... hussein

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

            c+- wrote: How to get current directory path in mfc?? This Code Will help

            //=========================
            // Get Current Path
            //=========================
            CString szCurrentDirectory;
            {
            CString csPath;

            //====================
            // Get File Path
            //====================

            ::GetModuleFileName(NULL,csPath.GetBuffer(MAX_PATH),MAX_PATH);

            csPath.ReleaseBuffer();

            //====================
            //Get current Directory
            //====================
            szCurrentDirectory=csPath.Left(csPath.ReverseFind('\\'));

            }

            "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

            1 Reply Last reply
            0
            • C c

              thanx.... hussein

              C Offline
              C Offline
              c
              wrote on last edited by
              #6

              thax guys!!! hussein

              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