0

Example :

1.When i using program start int x = 5;

2.Do something until x = 10

3.Closing program

4.When a relaunch program x will be equal to 10 (not 5)

KPTH
  • 91
  • 1
  • 2
  • 12
  • I would use registry, see [Read, write and delete from registry with C#](https://www.codeproject.com/Articles/3389/Read-write-and-delete-from-registry-with-C) – Pouya Abadi Jan 31 '17 at 04:37
  • 1
    Do not use the Registry without good reason. See [When - and why - should you store data in the Windows Registry?](http://stackoverflow.com/q/268424/1136211) – Clemens Jan 31 '17 at 11:06
  • I stand corrected :) – Pouya Abadi Feb 01 '17 at 23:52

1 Answers1

2

Here the Application Setting will come into play.

Proiperties -> Settings

enter image description here

This will strore our data as XMl formatted.

Action can be applied through both programmatically and manually.

Programmatically:

Create:

SettingsProperty property = new SettingsProperty(nameofthesetting);
property.DefaultValue = "Default";
property.IsReadOnly = false;
property.PropertyType = typeof(bool);
property.Provider = Properties.Settings.Default.Providers["LocalFileSettingsProvider"];
property.Attributes.Add(typeof(UserScopedSettingAttribute), new UserScopedSettingAttribute());
Properties.Settings.Default.Properties.Add(property);
Properties.Settings.Default.Reload();
property.DefaultValue = HereYourValue;

Update :

Settings.Default.YourSettingsName=NewValue
Settings.Default.Save();
Settings.Default.Reload();

reference,

How do I get around application scope settings being read-only?

How to update appSettings in a WPF app?

Community
  • 1
  • 1
Vijay
  • 663
  • 4
  • 15