I wonder. When you are in dubbingmode and develop you program you refer to ifstream like in the code below.

ifstream OneFile("Text.txt");

"Text.text" is in the folder debug. Later when the application is finished. I want the file "Text.txt" to be in a folder like this: C:\NewApplication\FileFolder\Text.txt

How am I going to do when I develop my program because the access later will be this directory.
Does this meen that I will change this later when the application is finished ?
Is it possible and correct to write:

ifstream OneFile("C:\NewApplication\FileFolder\Text.txt");

>Does this meen that I will change this later when the application is finished ?
Yes and no. When you run your application outside of the debugger (assuming you're using an IDE), a relative path will probably use the current working directory to look for files. Assuming you can make sure that the current working directory is "C:\NewApplication\FileFolder", you don't need to change the code at all.

If you can't set the current working directory, you'll need to store a debug path and a release path for the file somewhere, and use it conditionally. For example:

#define DEBUG_PATH "Text.txt"
#define RELEASE_PATH "C:\\NewApplication\\FileFolder\\Text.txt"

#ifdef DEBUG_MODE
#define TEXT_PATH DEBUG_PATH
#else
#define TEXT_PATH RELEASE_PATH
#endif
ifstream OneFile ( TEXT_PATH );

Then when you compile, define DEBUG_MODE (or not), and everything will magically work.

Thank you, that is a wonderful solution.
One thing more I wonder about is. Now my poject is under this
search Directory(debugmode)

C:\Documents and Settings\Andreassss\My Documents\Visual Studio 2008
[\quote]

Is it possible to change this to only c:\MyApplication and put my project here instead ?

Is there any setting for this.

Thank you...


>Does this meen that I will change this later when the application is finished ?
Yes and no. When you run your application outside of the debugger (assuming you're using an IDE), a relative path will probably use the current working directory to look for files. Assuming you can make sure that the current working directory is "C:\NewApplication\FileFolder", you don't need to change the code at all.

If you can't set the current working directory, you'll need to store a debug path and a release path for the file somewhere, and use it conditionally. For example:

#define DEBUG_PATH "Text.txt"
#define RELEASE_PATH "C:\\NewApplication\\FileFolder\\Text.txt"

#ifdef DEBUG_MODE
#define TEXT_PATH DEBUG_PATH
#else
#define TEXT_PATH RELEASE_PATH
#endif
ifstream OneFile ( TEXT_PATH );

Then when you compile, define DEBUG_MODE (or not), and everything will magically work.

>Is it possible to change this to only c:\MyApplication and put my project here instead ?
Sure, but it might not have the effect you want.

I notice you keep typing the path with only one backslash between folders. This was a problem I was having recently, remember in quotes and using backslashes you have to use two backslashes or "\\". The same is true for a quote mark inside quotes, "\"" or \". You probably know that already I just noticed though whenever you post you don't do it.

yes I know about the two \\. Just didnĀ“t write it out.

I am not sure if I understood if it is possible to change so I can have my debugfolder under c:\\
why I want to do this is because this application will always be changed so I will be working in C++ and remodify a piece of code all the time so to have this debugfolder under c:\ would be easy. The application will always be in a debugmode but it will be easy because then I can start to define all my searchways to c:\\

Is this possible to just move this debugfolder to c:\\ and debug it here all the time ?
Is there any searchway you can change in C++ to make that work.

Thanks

I notice you keep typing the path with only one backslash between folders. This was a problem I was having recently, remember in quotes and using backslashes you have to use two backslashes or "\\". The same is true for a quote mark inside quotes, "\"" or \". You probably know that already I just noticed though whenever you post you don't do it.

>Is this possible to just move this debugfolder to c:\\ and debug it here all the time ?
>Is there any searchway you can change in C++ to make that work.
You're getting into questions that can't be answered without knowing what compiler you're using.

Yes ofcourse. I use Visual C++ 2008 Express Edition and I am doing a Windows Form Application.


>Is this possible to just move this debugfolder to c:\\ and debug it here all the time ?
>Is there any searchway you can change in C++ to make that work.
You're getting into questions that can't be answered without knowing what compiler you're using.

In your project properties you can change the output directory. See if that does what you were expecting.

Wonderful again. That seemed to work great. I could change the outputdirectory to c:\\MyApplication and the changes made were changed to this directory.

Thank You...

In your project properties you can change the output directory. See if that does what you were expecting.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.