Adding a configuration file to your Windows Forms application can be a helpful way to manage your application’s settings. In this article, we’ll show you how to add a configuration file to an existing Windows Forms application. ..
But when you create the configuration file in the \bin\debug directory, it gets overwritten immediately when you do a new build. That’s slightly annoying.
The proper way to add this file is to add new new configuration file called App.config to your project, which Visual Studio will automatically copy and rename to the same name as your executable’s name when you do a build.
There’s a really simple way to do this.. simply go to the File \ Add New Item menu, or hit Ctrl+Shift+A
You’ll notice that it’s already set to App.config for you. Just hit the Open button.
If you look in the Solution Explorer, you will see that the config file is in your project:
Now build your application, and take a look in the \bin\debug\ folder. You’ll see that the configuration file has automatically been generated and named correctly for your executable:
If you change the name of the outputted file, Visual Studio is smart enough to generate the new filename correctly.
Enjoy Configuring!