What you want to do is save all the variables in a custom class serialize it using link this might help you.
How to Save all my variables into file to restore the program from the same point C#?
-
11-04-2022 - |
Question
i don't know if I'm explaining my self right but what i want is to save my program variables and information in one file and then start this file with this program.
my idea is like a .docx
file that opens with MS Word
and if this available can anyone show how to do it and how to make the computer start my program
when ever a file with a .yaser
extension is opened
thanks in advance to anyone that helps me :)
Solution 2
OTHER TIPS
You can put all the important data in a state class, and then serialize it to file in a binary, XML or JSON format. When your application is restarted, you can deserialize this file back to a class instance and use it.
For binary serialization look at BinaryFormatter, for XML - XmlSerializer, for JSON you can user JSON.Net
You may also need some plumbing code to rebuild caches, resubscribe to events, e.t.c.