Reputation: 6283
well i basically cant add an app.config file to my win forms project.
and i dont know if the application actually uses it or no.
i used "Add" > "New Item" > "Application Configuration File" but well i dont know if the app reads the data from the file or no.
so how can i know that the app actually reads that file?
thanks
Upvotes: 1
Views: 3085
Reputation: 158309
The file will be called "yourappname.exe.config"
in the output directory of your project. In order to test whether your application uses the file or not you can add a simple test to the code:
In the app.config file:
<configuration>
<appSettings>
<add key="testValue" value="Testing testing, one two three" />
</appSettings>
</configuration>
Basically anywhere in your application's code (preferably code that is executed during startup):
MessageBox.Show(ConfigurationManager.AppSettings["testValue"]);
You should see a message box with the value from the config file.
Upvotes: 4
Reputation: 1001
When you build, the app.config file will be copied as NameOfApplication.exe.config to the debug or release folder alongside the exe. That is the file that will be read.
Upvotes: 0
Reputation: 8190
1) The app.config file compiles as [yourProjectName].exe.config.
2) If any (basic) calls to ConfigurationManager work, it has read your app.config.
Upvotes: 1