Home

Awesome

SettingsProviders

This repository provides two custom implementations of the SettingsProvider class in the .NET Framework application settings architecture. They can be used to make the built-in application of WinForms and WPF application settings portable and more configurable:

Features

Usage

Note: Change all occurrences of PortableSettingsProvider to PortableJsonSettingsProvider to use the JSON version.

  1. Install the nuget package:
    Install-Package PortableSettingsProvider or
    Install-Package PortableJsonSettingsProvider
  2. Apply the provider to your settings:
    PortableSettingsProvider.ApplyProvider(Properties.Settings.Default);
    
    Make sure to adjust the name of the settings instance if it is not the default settings.
    For an alternative approach, see here.
  3. Optionally, you can set a different name and location for the settings file. A full configuration for a WinForms application might look like this:
static void Main()
{
	PortableSettingsProvider.SettingsFileName = "settings.config";
	PortableSettingsProvider.SettingsDirectory = "Some\\custom\\location";
	PortableSettingsProvider.ApplyProvider(Properties.Settings.Default);
	Application.Run(new Form1());
}

More

For a detailed explanation of the implementation and more options, visit the related CodeProject article. The article also explains the difference between roamed and local settings as the settings providers support both.

License

BSD-3-Clause License.