Search code examples
c#wpfapplication-settingssettings.settings

How can I add the application settings to my installer in a WPF project?


I do have a C# (WPF)-Application whith several application settings, generated in the Visual Studio 2010. With the "Advanced Installer" I would like to create an installer-setup in order to install my application to any PC.

Therefore I add to the installer the application.exe file from my release folder. After installation on a different PC I can not find the application settings which were generated in VS before. My question is now, which file(s) I need to add to my installer-package in order to see the application settings after installation?

Thanks in advance!


Solution

  • Application Scope Settings are persisted in the applications config file. It is located in the applications output directory and called [ApplicationName].exe.config. This is probably the one you want.

    User scope settings are persisted in the file User.config in the users settings folder:

    C:\Documents and Settings\[UserName]\Local Settings\Application Data\[ApplicationName]
    

    Vista and Windows 7, 8:

    C:\Users\[UserName]\Local Settings\Application Data\[ApplicationName]
    

    If you need to add the user config file to the installer package, make sure to use the correct directory in advanced installer. A helpful list is here. Use Local application data, create a subfolder with your app name there and add user.config to this folder:

    enter image description here

    You can find more info here.