Using appSettings

B

Bob

Hello,

I have a console app and would like it to pick up some settings from the
application config file....

Can anybody give me the basic rundown on the simplest way to achieve this...
the MSDN stuff for this is really quite vague and does not seem to work when
I do it the MS way in my code.

Anyway, say I have my app.exe.config file with a setting called DebugMode
and a value of "true". No matter how I use the system.configuration methods
I can't retrieve the value...

For starters I need to know... do I create the app.exe.config file in the
bin folder (where file keeps getting deleted) or in same folder as my
solution (if here, should it be called app.config)?

Anybody care to enlighten me?

Cheers
 
R

Rob Windsor [MVP]

Configuration files need to be in the same folder as the EXE and have the
same name with ".config" appended. For example is your EXE is
c:\MyApp\MyApp.exe then the config file needs to be
c:\MyApp\MyApp.exe.config.

App.config is a Visual Studio shortcut you can use. When you ask VS to add
an application configuration file to your project it will add the file
called App.config and put it in the same folder as your source code. When
you build your project, VS will copy App.config to the build folder and
rename it as required.

Hope this helps.
 
G

Guest

Just another comment, when you add the application configuration file ensure you don't tamper with the file name, otherwise the file won't be copied to the compile output of the project (bin directory).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top