J
J
jle349252015-12-04 23:41:35
Programming
jle34925, 2015-12-04 23:41:35

C# console application, save state before closing how?

It is required to save the state of the program if the console application is closed, how to do it? Event? Which? Or how?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
M
Melz, 2015-12-05
@jle34925

Well, it's better to do it outside the event and save it in the parameters . For example, input data as soon as you receive it. Or just in a file.
Of course, there is AppDomain.ProcessExit , but it will not be called when killing the program through the task manager or Ctrl+C /break.
Then you need to subscribe to Console.CancelKeyPress .

E
eRKa, 2015-12-05
@kttotto

I would add a Setting file (a link to working with the settings file was left to you by the post above), in which I would add the necessary parameters to run the application. At the beginning of the application would take data from there. When these parameters change during operation, save them in this file. And no matter how the application closes, the current state will be saved in the setting.

V
Vitaly Vitrenko, 2015-12-05
@Vestail

For this serialization is used . But it's not entirely clear what exactly you want.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question