Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
How To: Write User Settings at Run Time with C#

How To: Write User Settings at Run Time with C#

Settings that are application-scoped are read-only, and can only be changed at design time or by altering the .config file in between application sessions. Settings that are user-scoped, however, can be written at run time just as you would change any property value. The new value persists for the duration of the application session. You can persist the changes to the settings between application sessions by calling the Save method.

How To: Write and Persist User Settings at Run Time with C#

  1. Access the setting and assign it a new value as shown in this example:

    // C#
    Properties.Settings.Default.myColor = Color.AliceBlue;
    
  2. If you want to persist the changes to the settings between application sessions, call the Save method as shown in this example:

    // C#
    Properties.Settings.Default.Save();
    

    User settings are saved in a file within a subfolder of the user’s local hidden application data folder.

Show:
© 2015 Microsoft