How to set working directory in a Visual Studio 2010 project?

user579674 picture user579674 · Jun 13, 2011 · Viewed 8.2k times · Source

My project is in C# Windows Forms. While debugging, I was using the debug folder as the working directory but now that I will deploy my project I need to specify a working directory. How do I do it?

Answer

Jon Skeet picture Jon Skeet · Jun 13, 2011

You can set it programmatically with Environment.CurrentDirectory - but normally it's simply determined by how the program is executed. For example, if you start the app by double-clicking on it, the working directory will be the one containing the executable. If you start it from the command line, it will be the current directory of the console at the time.

Why does it matter in your code, and what are you trying to set it to?