I do not understand the following things:
- What is the difference between app.config (applicationname.exe.config) and settings file ?
- I am unable to locate the *.settings file in Windows7 AppData directory under the specific account (I heard that it should be located somewhere over there) ?
- Let's assume that *.settings file is somewhere on the hard drive. Why on the development time the data from settings file are copied to application config file?
Kind Regards PK
The app.config file represents settings intrinsic to the application, and will apply to all sessions of the application. The *.settings file is typically for settings specific to a given user's use of an application.
Try looking in the Application Data directory beneath Local Settings [«username»\Local Settings\Application Data\«app name ...»], instead of the user's direct Application Data directory [«username»\Application Data].
The copy of the settings in the app.config file for a given *.settings file are used to initialize it the first time those settings are used; including the case when a new setting is added and a prior copy of the *.settings file doesn't have the new setting yet.
Here is a link for a brief walk-through of settings in C#.
Using Settings in C# (MSDN)
So the default settings are stored in the
<exename>.config
file located in the same directory as the executable.The reason you do cannot find the user.config file is it is only created if you have made changes to the defaults. The user settings override the defaults which are stored in the
<exename>.config
file. If no changes have been made, then no user configuration file will exist. And... once it does exist you will notice that only the settings which have been changes will show up in the user.config file.To test this... create a dummy variable called like temp in your Settings file. When you start your application do:
You will now have a file called user.config created in the user's ApplicationData folder which on Vista is in:
C:\Users\<username>\AppData\Local\<company>\<productname>
Here is some code I wrote to help identify where all the various SpecialFolders where on different Operating Systems. (Might want to do a find-replace for
log.Debug
and replace withConsole.WriteLine
)Output On Windows Server 2003:
Output on Vista: