Search code examples
c++visual-studio

Path to input files in VS 2019


Visual Studio does not seem to be finding input files when I try to compile under "Debug":

/* in.dat exists in 

\ProjectName\
\ProjectName\Debug\
\Debug\

*/

string name = "in.dat";
ifstream ifs(name); // nullptr...

Are there specific places VS looks for input files? Specifying an absolute pathname did not solve the problem.


Solution

  • Visual Studio Working Directory

    There is a setting in the current project settings for working directory. When you build a project in visual studio, the executable is run in this directory, regardless of which directory the executable is in. The working directory is found under Project Settings >> Configuration Properties >> Debugging More information about properties pages: https://learn.microsoft.com/en-us/cpp/build/working-with-project-properties?view=vs-2019