MoonKnight
MoonKnight

Reputation: 23831

Where the Devil is my Applications .config file?

All, I have a large application. This application uses a .config file to deal with its various settings. This is fine in development, and the .config file is found and working happily in the respective \bin folders (Release and Debug). I have written a NSIS installer an I am now running the app; it is working perfectly, saving settings, restoring settings and generally being a good LAD.

However, the 'MyApp.exe.config' is not where the settings are being written (I have checked and even deleted this so it could be recreated). It is also not in ...Users\Me\AppData\Roaming\MyApp?

Where the Devil is my applications config file?

Thanks again for your time.

Edit. I have printed out System.Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) and this points to the Roaming AppData directory above.

Upvotes: 2

Views: 472

Answers (1)

Chris Chilvers
Chris Chilvers

Reputation: 6479

The configuration system for .net gets its settings from several locations.

General config comes from:

  1. The first location is the machine.config file that ships with the .net framework.
  2. The next location is the application's configuration file.

Next the settings API gets values from (using the default provider):

  1. Hard-coded defaults when the app was compiled.
  2. The application configuration file.
  3. The user's settings file.

If the application's configuration file does not exist it will not be automatically created (doing so would be pointless since it would only contain the defaults the application already knows).

Saving the settings will however create a new user settings file as normal.

Upvotes: 1

Related Questions