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 :)
Asked
Active
Viewed 112 times
-1

Yaser Jaradeh
- 322
- 1
- 6
- 27
-
Have you looked at the [`Settings`](http://msdn.microsoft.com/en-us/library/aa730869.aspx) file? – Oded Apr 23 '13 at 18:25
-
You can use XML to store last data, then restore from that XML file. – Javidan Apr 23 '13 at 18:25
2 Answers
2
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.

alex
- 12,464
- 3
- 46
- 67
-
Here is a sample for XmlSerializer - http://support.microsoft.com/kb/815813 , you can easily google the samples for other methods as well – alex Apr 23 '13 at 18:29
1
What you want to do is save all the variables in a custom class serialize it using link this might help you.

bhupendra patel
- 3,139
- 1
- 25
- 29