You can use ApplicationExit instead.
Application.ApplicationExit += new EventHandler(Application_ApplicationExit); void Application_ApplicationExit(object sender, EventArgs e) { Settings.Default.Save(); }
Alternatively, you can also save with every change:
Settings.Default.PropertyChanged += new PropertyChangedEventHandler(Default_PropertyChanged); void Default_PropertyChanged(object sender, PropertyChangedEventArgs e) { Settings.Default.Save(); }
Warning: if you are using the second approach, consider @Hans Passant's comments
Fun mun pieng
source share