YAKOVM
YAKOVM

Reputation: 10153

relative path couldn't be opened

In the project i am working on, during run-time I need to open some file and read it

std::ifstream vSettings(".\\..\\..\\Data\\data.xml");
if (vSettings.good())
{


    //file found ,work with it

}

I never get true for the good() call above. Manually I checked that the file indeed exists relatively to the .exe.

the path to exe is \main\proj\bin\Debug-Win32.the path to file main\proj\Data.When running in the user computer the directory will be installed relatively to the .exe

I work in debug mode and path is as it looks from the "bin" directory point of view.

Any advises?

Upvotes: 1

Views: 344

Answers (1)

Eric
Eric

Reputation: 19863

Go to the Debugging settings

enter image description here

and change the $(ProjectDir) to $(OutDir), and it should behave like you expect

Upvotes: 2

Related Questions