Windows App: [ConfigurationSettings.AppSettings]

  • Thread starter Thread starter Filippo
  • Start date Start date
F

Filippo

Hi there,
I am writing a Windows App and need a Configuration file.

I wonder if I can use the WEB.CONFIG file to store my values.
I also wonder if I can use the ConfigurationSettings.AppSettings and if so,
what is the file name that it automatically look for.

Thanks,
Filippo
 
Filippo,
Within a Windows App, the web.config is called app.config, you continue to
use ConfigurationSettings.AppSettings to get values &
ConfigurationSettings.GetConfig to get custom sections.

Within your VS.NET project you need to add your config file to your VS.NET
project's root folder as app.config, it needs to be named "app.config"
without the quotes. When you
build your project VS.NET (both 2002 & 2003) will copy the app.config file
from the project root to your output folder and name it appropriately
(myproject.exe.config).

It is important that you add the file to your VS.NET project as app.config.
While when you deploy your app you call it myproject.exe.config where
myproject is the name of your executable, and myproject.exe.config is in the
same folder as your exe.

Hope this helps
Jay
 
Jonathan,
Please read what I said, it cannot be called yourappname.exe.config in the
VS.NET project! Period! (Actually it can but it will not be copied, so what
good is it?)

Also if you are using VS.NET 2003 it has to be in the root folder of your
VS.NET project, as VS.NET 2003 will replace any config file in your output
folder (the output folder is normally bin) to ensure that the copy in your
bin folder matches the Supported Runtimes setting under the Project Property
Pages.

VS.NET 2002 supports the app.config in your project root, however VS.NET
2002 does not remove it from the output folder.

Try it, I have.

Hope this helps
Jay
 
Back
Top