Read Write Settings at Run Time With C#

Read Write Settings at Run Time With C#

Added by Mind Hunter updated on Wednesday, January 3, 2018

Read Settings:

We can read both Application-scoped and User-scoped settings at run time via the Properties object. The Properties object exposes all of the default settings for the project via the Properties.Settings.Default member.

this.Text = Properties.Settings.Default.myCaption; 				
				

Where Properties.Settings.Default.myCaption is previously created at Design Time.

Write Settings:

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.

Properties.Settings.Default.myCaption="My New Caption";				
Properties.Settings.Default.Save();
Properties.Settings.Default.Reload();
				

Properties.Settings.Default.Reload() is used to reflect changes to Application.

Related Tags

About

27 Tutorials
24 Snippets
6 Products

More

Contact Us

Contact us

Stay Connected