I need to run some code after my application is exited (it's a C# and WPF application, developped with VisualStudio).
Basically, when an update is available, the application should exit, copy new files (from our server to the user computer), and open again (of course, after user confirmation, and all other checks).
I am able to manage the update, but when I copy new files, I have an error saying some files are in use (which is indeed normal).
How can I do that ?
For example, my "update" method is as follow :
try
{
// Need to close the app here i guess
// File copying : it's ok here
// Open the app again
}
catch (Exception e)
{
MessageBox.Show("Cannot update\n" + e.Message, "MyApp", MessageBoxButton.OK, MessageBoxImage.Error);
Environment.Exit(1);
}
Thank's a lot for helping me to perform this task.