Good day.
There is a working application myapp.exe which downloads a new version from the server and puts it next to myapp.exe under the name. myapp.update.
How can I replace myapp.exe with a new myapp.exe?
Tried to make an additional project.
At the end the main project performs
Updater.MainWindow update = new Updater.MainWindow(); update.Show(); System.Diagnostics.Process.GetCurrentProcess().Kill(); But the main project window remains open but in the frieze.
The project in which Update is registered does not appear until the last action and closes immediately
public MainWindow() { InitializeComponent(); Thread.Sleep(5000); UpdateNow(); } public void UpdateNow() { bool oldapp = false; bool newapp = false; Changes.Content = "Идет проверка целостности файлов..."; string path = System.IO.Directory.GetCurrentDirectory(); string[] allFoundFiles = Directory.GetFiles(path, "myapp.exe"); foreach (string file in allFoundFiles) { oldapp = true; } string[] allFoundFiles1 = Directory.GetFiles(path, "myapp.update"); foreach (string file in allFoundFiles) { newapp = true; } if (oldapp == true && newapp == true) { Changes.Content = "Все файлы на месте. Идет применение настроек..."; Thread.Sleep(5000); try { FileInfo fi1 = new FileInfo(path + @"\myapp.exe"); fi1.Delete(); } catch (Exception ex) { Changes.Content = ex.ToString(); } try { System.IO.File.Move(path + @"\myapp.update", path + @"\myapp.exe"); Changes.Content = "Все готово к работе :)"; System.Diagnostics.Process.Start(path + @"/myapp.exe"); } catch (Exception ex) { Changes.Content = ex.ToString(); } } else { Changes.Content = "Что - то не так"; } } } Not only that Update does not give signs of life. The "Access Denied" error appears when deleting the old myapp.exe. And why it closes by itself.