How to change working directory in Visual Studio for a C/C++ app

Posted by Blake on 6/11/2015


I have a C application (a mud server that I work on in my spare time. I typically run it on a Linux box but sometimes it's nice to compile and debug through Visual Studio.

To make a long story short, whenever you click play/run you typically think the directory where the application was compiled to is where it would run from (and you would be wrong, this is unituitive especially if you typically code in .net like I do). For whatever reason in C/C++ project starts up in the directory that contains the project file and not where it's built to (which in my case contains area files that I need to read in).


To change this behavior and have the working directory be the one where the executable resides follow these steps:

  1. Open Project -> Properties -> Configuration Properties -> Debugging.
  2. The working directory entry is "$(ProjectDir)" by default. To change it to the place the execute resides change the value to "$(SolutionDir)$(Configuration)\".

I've tested this with Visual Studio 2013 on Windows 7 x86, Windows 7 x64 and Windows 8.1 x64.