- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I have changed default path of the command prompt according to this guide:
http://www.ghacks.net/2007/11/16/change-the-default-command-prompt-directory/
to "E:\\C++\\" For some reasons, now when I want to "start without debugging" (either in debug or release) it says that the file cannot be found in E:\\C++\\.
My open command is as: OPEN(10,FILE='grid1.plt'). grid1.plt is in the same directory as of the source code and when I "Start debugging" it runs untill the end! What should I do?
http://www.ghacks.net/2007/11/16/change-the-default-command-prompt-directory/
to "E:\\C++\\" For some reasons, now when I want to "start without debugging" (either in debug or release) it says that the file cannot be found in E:\\C++\\.
My open command is as: OPEN(10,FILE='grid1.plt'). grid1.plt is in the same directory as of the source code and when I "Start debugging" it runs untill the end! What should I do?
Link Copied
4 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Change the default path back to the project directory (or project build directory)
What you have done is equivilent to command lines:
(somewhere)>E:
E:\>CD \C++
E:\C++>C:\YourProjectBuildPathHere\YourProgram.exe [optional args]
Your open with 'grid1.plt' with no drive and path uses "current directory" (now E:\C++) and not the run from directory (C:\YourProjectBuildPathHere\). Either change the default path back to the project or project build (Debug/Release/other) or obtain the run from directory from the comman line arg 0 (or use a Windows API which I did not bother to look up for you). Note, the arg 0 (usually, but not always) provides the full path and file name of what was run. From there you can chop off the program name to get the folder from which the file was run. Until you move/copy the program this will be the project build directory.
Jim Dempsey
What you have done is equivilent to command lines:
(somewhere)>E:
E:\>CD \C++
E:\C++>C:\YourProjectBuildPathHere\YourProgram.exe [optional args]
Your open with 'grid1.plt' with no drive and path uses "current directory" (now E:\C++) and not the run from directory (C:\YourProjectBuildPathHere\). Either change the default path back to the project or project build (Debug/Release/other) or obtain the run from directory from the comman line arg 0 (or use a Windows API which I did not bother to look up for you). Note, the arg 0 (usually, but not always) provides the full path and file name of what was run. From there you can chop off the program name to get the folder from which the file was run. Until you move/copy the program this will be the project build directory.
Jim Dempsey
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Well I took the simplest way and changed the directory to default, but I was wondering if there is any option that tells open command use relative directory? this piece of code does not worth involving in APIs
thanks anyway
thanks anyway
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Set the property
Project->Properties->Configuration Properties->Debugging->Working Directory
to the location of the data files.
Or, choose for the value of this property some directory that is a parent of the one where the data files reside, and in your program specify the relative path from the property value just entered.
When you say "relative" the associated question of "relative to what" needs to have a known answer.
Project->Properties->Configuration Properties->Debugging->Working Directory
to the location of the data files.
Or, choose for the value of this property some directory that is a parent of the one where the data files reside, and in your program specify the relative path from the property value just entered.
When you say "relative" the associated question of "relative to what" needs to have a known answer.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You are using relative directory. The problem is... you are setting the "current directory" to somewhere else than the location of the program
C:\YourProjectFolder>dir
C:\YourProjectFolder>Release\YourProgram.exe
lists the current directory C:\YourProjectFolder
And your OPEN will use the relative directory "." == C:\YourProjectFolder
(although the program resides in C:\YourProjectFolder\Release")
C:\YourProjectFolder>E:
E:\>cd C++
E:\C++>dir
E:\C++>C:\YourProjectFolder>Release\YourProgram.exe
Lists the current directory E:\C++
Andyour OPEN will use the relative directory "." == E:\C++
(although the program resides in C:\YourProjectFolder\Release")
It is yourresponsibility to specify the location(drive and folder) to which you wish things to be relative.
VS has a property page for doing this.
Or when you runby command line or by shortcut you can manipulatethe current drive and directory via actions (commands)or properties (shortcut).
What you cannot do is assume the system can read your mind.
Jim Dempsey
C:\YourProjectFolder>dir
C:\YourProjectFolder>Release\YourProgram.exe
lists the current directory C:\YourProjectFolder
And your OPEN will use the relative directory "." == C:\YourProjectFolder
(although the program resides in C:\YourProjectFolder\Release")
C:\YourProjectFolder>E:
E:\>cd C++
E:\C++>dir
E:\C++>C:\YourProjectFolder>Release\YourProgram.exe
Lists the current directory E:\C++
Andyour OPEN will use the relative directory "." == E:\C++
(although the program resides in C:\YourProjectFolder\Release")
It is yourresponsibility to specify the location(drive and folder) to which you wish things to be relative.
VS has a property page for doing this.
Or when you runby command line or by shortcut you can manipulatethe current drive and directory via actions (commands)or properties (shortcut).
What you cannot do is assume the system can read your mind.
Jim Dempsey

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page