Bear23

I want to write to an external app.config or settings.settings file that is located c:\windows.

I have vs2005 how would I do this. i would then need to read this external file as well.

I am taking that the app.config and settings.settings is the same thing.



Re: Visual C# General app.config or settings.settings

TaylorMichaelL

No they aren't. App.config is the application configuration file and is part of the application itself. settings.setting is a source file that is eventually compiled into code.

Settings that are defined in the project property pages are stored in app.config and the user configuration file at runtime. App.config contains the read-only default values whereas user changes are normally stored in user config. The settings.setting file will never be deployed. If you look at the file you'll find a class that exposes each of the settings you define as properties off a settings class to make settings easier to use. However the code becomes part of the assembly during compilation.

Note that app.config gets renamed to applicationname.exe.config before running.

Michael Taylor - 12/28/06





Re: Visual C# General app.config or settings.settings

Bear23

Then why when I create a setting it adds an app.config file to the project. You did state whether what I am trying to do can be achieved and how.





Re: Visual C# General app.config or settings.settings

TaylorMichaelL

Application settings are stored in the app.config file. You'll find a section that contains each of your settings along with the type and default value. This allows the application at runtime to get access to the default settings available. If you define a setting as user scope then the setting will also be stored in the user's local config file (since they won't have write access to the app config). This probably only occurs when the user changes the setting (through your UI). Nevertheless the app.config holds the settings for the application plus the defaults for the user settings.

Now settings.setting is a code file. If you open it up (the actual source file, double clicking will take you to the project's settings page) you'll find that it is nothing more than a class that exposes each of the settings from the config file as properties. This allows you to programmatically access the settings at runtime without having to interact with the configuration subsystem (which is how you access the app.config) file.

You almost never should mess with the settings.setting file. It is dynamically generated each time you use the project property pages to add or edit a setting. You should also normally not muck with the app.config settings either as you might mess up the syntax. Instead you should use the project's property pages to add and edit settings. However if you wanted to, for example, copy the settings from one application to another you could open the app.config file and copy the section from one application to another. You would then need to open the project's property pages to force the IDE to generate/update the settings.setting file.

Michael Taylor - 12/28/06
http://p3net.mvps.org





Re: Visual C# General app.config or settings.settings

Bear23

I get it...

thank you.