Hi,
I need to keep in memory a value that the user would have enterred. i don't even know if it is possible
Can you help me
Visual C# General
Hi,
I need to keep in memory a value that the user would have enterred. i don't even know if it is possible
Can you help me
For how long do you need to keep it in memory Do you mean you want to keep it after your application exits
Hi,
so you want to persist a value even after the user has closed the application, so that if they open a new instance of the application it can use the same value If so you could write the value to the registry, a file such as an XML file of the App.Config file, that way when the application starts up you can read the value back into memory, is that what you want to do
Mark.
First of all keep in mind, When applicaiton is closed all memory it used is gone. So you cannot keep a reference of that (Atleast not in the modern Languages).
The best thing you can do is ofcourse would be the use of Client Settings of .Net.
Simply create a new key put a value in it and go... You can also add your own Custom types in Client Setting.
To do it, Double Click Settings.setting under Properties in Solution Explorer
I hope you will get what to do next.
When a Key is created simply from your code you can access that in read/write mode using:
global::<namespacename>.Properties.Settings.Default.<KeyName>
After updating the value you can call global::<namespacename>.Properties.Settings.Default.Save();
method to save changes.
Next time when you'll run the program you will be able to access the saved data from it.
Its simple and safe. Registry may cause security exception, can cause complexity same is the case to do it with custom config files.
Best Regards,
Rizwan aka RizwanSharp