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
views:
35answers:
3
+1
A:
1) The app.config file compiles as [yourProjectName].exe.config.
2) If any (basic) calls to ConfigurationManager work, it has read your app.config.
AllenG
2010-08-16 20:55:57
A:
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.
Chris
2010-08-16 20:57:06
+1
A:
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.
Fredrik Mörk
2010-08-16 20:57:43