Files
docs-desktop/dotnet-desktop-guide/framework/winforms/advanced/how-to-write-user-settings-at-run-time-with-csharp.md
Andy De George c0ba284473 Initial winforms content migrated (#18)
* Merge winforms framework content to working branch (#14)

* Breadcrumb / TOC / Move net5 to net folder (#15)

* change path from net5 to net

* Mess with bread/toc

* Mess with bread/toc

* Mess with bread/toc

* Mess with bread/toc

* Mess with bread/toc

* Mess with bread/toc

* Mess with bread/toc

* Mess with bread/toc

* Mess with bread/toc

* Mess with bread/toc

* Mess with bread/toc

* Mess with bread/toc

* Mess with bread/toc

* Mess with bread/toc

* Add .net 5 winforms placeholder article (#16)

* added some metadata and adjusted net5 placeholder

* corrections

* corrections

* corrections

* Test1

* Swapping landing page vs concept

* fix links

* Fix links

* Fix desc
2020-09-01 16:26:21 -07:00

1.8 KiB
Raw Permalink Blame History

title, description, ms.date, helpviewer_keywords, ms.assetid
title description ms.date helpviewer_keywords ms.assetid
How To: Write User Settings at Run Time with C# Learn how to write settings at run time with C# by persisting the changes to the settings between application sessions by calling the Save method. 03/30/2017
application settings [Windows Forms], run time
application settings [Windows Forms], writing user settings
application settings [Windows Forms], C#
9d061c7d-b33b-470f-a36d-edccb1d6f9a3

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:

    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:

    Properties.Settings.Default.Save();  
    

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

See also