Settings.settings` stores preferences on the disk. Writing a setting to disk when a program exits and then reading it back when the program is started again is cumbersome. We can use instead the Settings.settings file.`480px`300px`Intro.` There are some mechanisms for programmers to easily store settings on the disk, and access them in memory whenever needed. This helps improve speed of development and the feature set of programs. It makes programs faster to develop.`We get started` through the Visual Studio C# development environment. In a typical Windows Forms project, there is a folder called Properties and a file called Settings.settings in that folder. `Next: `We set up settings. We look at the steps you need to take to get this properly configured.`First steps to take.` Select the file. Then, please double click on the Settings.settings file and you should see a settings table. Next, type a name of the variable in the leftmost column. `Then: `In the same row, set the type (int, string). Finally, set the value in the right side.`Understanding application/user.` Select whether it is an application setting or a user setting. This indicates whether the setting will be changed by the user or not. Also, the user setting is reset by each user installation.`Scope column.` There is a Scope column in the table in Visual Studio. There are two options in each cell there: Application and User. Next, we describe the scope values available and their meanings. `Application: `Not changed by the user. It is constant in every instance of the application.`User: `The setting is not constant throughout each instance. It is reset for each user installation.`Code.` The real bonus that C# and .NET provide in this situation is the ease of use of the syntax and the clarity of the required code. Here's what I do when I want to start up the program and retrieve the string and display it in a text box. `There are no complicated` constructors or method calls. When the program is being exited, an event handler called FormClosing is called. Here is how I set the saved input string to the last input string. `Note on FormClosing event.` There is one method call that needs to be made when the program exits. That is easy to do, however, and making a simple FormClosing event handler is sufficient. `Next: `I want to show an example using a different data type. Here's how to retrieve a value from the settings.`Summary.` We saw ways to use the Settings.settings file in Visual Studio with the C# language. The resources are automatically turned into regular properties. This is useful for developing applications quickly. `Review: `Using this convenient mechanism to persist application and user settings. It allows us to focus on the core of an application.

OHLUYCode that loads settings HP: C#YLLY//LH{HuHpa Hh from the Setting.settings file showHpthe aboveLH{screenshot. USavedInputHOU is just a custom variable which canLH{be named anythingHpyour program. Set the Text of an input boxLH{to the property.L//LYinputBox.TextHyProperties.YSettingsY.Default.SavedInputHO;YCode that sets propertyHpFormClosing: C#YLLHcTextWindow_FormClosing(object sender, FormClosingEventArgs e)L{YLO//LOH{We are goingHjwriteHjthe settingsHpour code. We take the HMsLOH{of a function,HVset the settings HP equalHjit.LO//LOYProperties.YSettingsY.Default.SavedInputHOHySanitizeInput(inputBox.Text);YLLO//LOH{Now, we needHjsave the settings file. If we don't save it, theyLOH{disappear. By saving it, we will be ableHjuse all the settings exactlyLOH{as they are now, the next time the program is run.LO//LOYProperties.YSettingsY.Default.Save();L}YCode that retrieves setting: C#YLLY//LH{Retrieve a Hh from the Settings.settings file. The HPLH{was manually addedHjthe settings fileHpthe tableHpVisual Studio.L//LYlong expireTimeHyProperties.YSettingsY.Default.ExpireMs;Y