I’m trying to write my Textbox Text into a config file in C# Winfroms to save the text. This is what I have done so far:
The code to save the settings:
Properties.Settings.Default.saveToTextBox = saveToTextBox.Text;
The code to load the settings:
saveToTextBox.Text = Properties.Settings.Default.saveToTextBox;
`
And the Events FormClosed and Load to save and load it.
But if I reopen my program the textbox remains empty.
>Solution :
To persist the changes to Settings between application sessions, call the Save method:
Properties.Settings.Default.Save();
This should work both for .NET Framework 4 and for .NET 6/7.
Settings are saved in a file within a subfolder of the user’s local hidden application data folder.