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 set The Path?

How to set The Path?

Scheduled Pinned Locked Moved C / C++ / MFC
questiondebugginghelptutorialworkspace
5 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.
  • R Offline
    R Offline
    rajeev82
    wrote on last edited by
    #1

    Hi all, In my application I'm reading a file which is present in the project workspace . when the exe is copied to the desktop from the debug folder and run from there, I'm getting an error message which says,"THE FILE COULD NOT BE OPENED" How do i make the exe to look in to a specfic folder where i've kept the files? Thanks in Advance. Rajeev

    O V T V 4 Replies Last reply
    0
    • R rajeev82

      Hi all, In my application I'm reading a file which is present in the project workspace . when the exe is copied to the desktop from the debug folder and run from there, I'm getting an error message which says,"THE FILE COULD NOT BE OPENED" How do i make the exe to look in to a specfic folder where i've kept the files? Thanks in Advance. Rajeev

      O Offline
      O Offline
      Owner drawn
      wrote on last edited by
      #2

      rajeev82 wrote:

      when the exe is copied to the desktop from the debug folder and run from there, I'm getting an error message which says,"THE FILE COULD NOT BE OPENED"

      Yeah this will happen because the exe looks for files in it's path i.e the path from where it started up(not always) i.e. desktop. You've got to mention the filename path to solve this. Or else you can do this. Put the file where the exe is. Then you use this function to get the path of the exe: GetModuleFileName(...) Append this path to the file name. Then it will work always.

      Jesus Loves:rose:

      --Owner Drawn:rose: --Nothing special --Defeat is temporary but surrender is permanent --Never say quits --Jesus is Lord:rose:

      1 Reply Last reply
      0
      • R rajeev82

        Hi all, In my application I'm reading a file which is present in the project workspace . when the exe is copied to the desktop from the debug folder and run from there, I'm getting an error message which says,"THE FILE COULD NOT BE OPENED" How do i make the exe to look in to a specfic folder where i've kept the files? Thanks in Advance. Rajeev

        V Offline
        V Offline
        vallikumar
        wrote on last edited by
        #3

        Hi, If you have a file other than your application's folder, then you should tell the exact path statically to your application. If you are storing the file in your application or temporary or system folders then you can use functions to get the file's folder. :cool: regards Vallikumar A

        1 Reply Last reply
        0
        • R rajeev82

          Hi all, In my application I'm reading a file which is present in the project workspace . when the exe is copied to the desktop from the debug folder and run from there, I'm getting an error message which says,"THE FILE COULD NOT BE OPENED" How do i make the exe to look in to a specfic folder where i've kept the files? Thanks in Advance. Rajeev

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

          rajeev82 wrote:

          How do i make the exe to look in to a specfic folder where i've kept the files? Thanks in Advance.

          try SetCurrentDirectory and GetCurrentDirectory api

          "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
          • R rajeev82

            Hi all, In my application I'm reading a file which is present in the project workspace . when the exe is copied to the desktop from the debug folder and run from there, I'm getting an error message which says,"THE FILE COULD NOT BE OPENED" How do i make the exe to look in to a specfic folder where i've kept the files? Thanks in Advance. Rajeev

            V Offline
            V Offline
            vikas amin
            wrote on last edited by
            #5

            Hi rajeev how ru ? If u r using the CFile class then try this . CFile file; CFileException fe; if (!("C:\\Test.xml", CFile::modeCreate |CFile::modeReadWrite | CFile::shareExclusive, &fe)) { //handle the exception } Vikas Amin Embin Technology Bombay -- modified at 8:15 Wednesday 18th January, 2006

            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