private void ApplyUpdateFromStream(MemoryStream updatearchive)
        {
            Log.Information("Extracting update from memory");
            ; SevenZipExtractor sve = new SevenZipExtractor(updatearchive);
            var outDirectory        = Directory.CreateDirectory(Path.Combine(Utilities.GetTempPath(), "Update")).FullName;

            sve.ExtractArchive(outDirectory);
            var updaterExe = Path.Combine(outDirectory, "ME3TweaksUpdater.exe");

            Utilities.ExtractInternalFile("MassEffectModManagerCore.updater.ME3TweaksUpdater.exe", updaterExe, true);
            var updateExecutablePath = Directory.GetFiles(outDirectory, "ME3TweaksModManager.exe", SearchOption.AllDirectories).FirstOrDefault();

            if (updateExecutablePath != null && File.Exists(updateExecutablePath) && File.Exists(updaterExe))
            {
                ProgressText = "Verifying update";
                var isTrusted = AuthenticodeHelper.IsTrusted(updateExecutablePath);
                if (!isTrusted)
                {
                    Log.Error("The update file is not signed. Update will be aborted.");
                    Application.Current.Dispatcher.Invoke(() =>
                    {
                        Xceed.Wpf.Toolkit.MessageBox.Show(Window.GetWindow(this), "Unable to apply update: ME3TweaksModManager.exe in the update archive is not signed and is therefore not trusted.", "Error applying update", MessageBoxButton.OK, MessageBoxImage.Error);
                        OnClosing(DataEventArgs.Empty);
                    });
                    return;
                }
                ProgressText = "Applying update";
                string args = $"--update-boot";
                Log.Information("Running new mod manager in update mode: " + updateExecutablePath + " " + args);

                Process process = new Process();
                // Stop the process from opening a new window
                process.StartInfo.UseShellExecute = false;
                process.StartInfo.CreateNoWindow  = true;

                // Setup executable and parameters
                process.StartInfo.FileName  = updateExecutablePath;
                process.StartInfo.Arguments = args;
                process.Start();
                process.WaitForExit();

                ProgressText = "Restarting Mod Manager";
                Thread.Sleep(2000);

                args = $"--update-from {App.BuildNumber} --update-source-path \"{updateExecutablePath}\" --update-dest-path \"{App.ExecutableLocation}\"";
                Log.Information("Running updater: " + updaterExe + " " + args);

                process = new Process();
                // Stop the process from opening a new window
                process.StartInfo.UseShellExecute = false;
                process.StartInfo.CreateNoWindow  = true;

                // Setup executable and parameters
                process.StartInfo.FileName  = updaterExe;
                process.StartInfo.Arguments = args;
                process.Start();
                Log.Information("Stopping Mod Manager to apply update");
                Log.CloseAndFlush();
                Environment.Exit(0);
            }
            else
            {
                Log.Error("Could not find ME3TweaksModManager.exe! Update will be aborted.");
                Application.Current.Dispatcher.Invoke(() =>
                {
                    Xceed.Wpf.Toolkit.MessageBox.Show(Window.GetWindow(this), "Unable to apply update: ME3TweaksModManager.exe was not found in the archive.", "Error applying update", MessageBoxButton.OK, MessageBoxImage.Error);
                    OnClosing(DataEventArgs.Empty);
                });
            }
        }
        private void ApplyUpdateFromStream(MemoryStream updatearchive)
        {
            Log.Information(@"Extracting update from memory");
            ; SevenZipExtractor sve = new SevenZipExtractor(updatearchive);
            var outDirectory        = Directory.CreateDirectory(Path.Combine(Utilities.GetTempPath(), M3L.GetString(M3L.string_update))).FullName;

            sve.ExtractArchive(outDirectory);
            var updaterExe = Path.Combine(outDirectory, @"ME3TweaksUpdater.exe");

            Utilities.ExtractInternalFile(@"MassEffectModManagerCore.updater.ME3TweaksUpdater.exe", updaterExe, true);
            var updateExecutablePath = Directory.GetFiles(outDirectory, @"ME3TweaksModManager.exe", SearchOption.AllDirectories).FirstOrDefault();

            if (updateExecutablePath != null && File.Exists(updateExecutablePath) && File.Exists(updaterExe))
            {
                ProgressText = M3L.GetString(M3L.string_verifyingUpdate);
                var isTrusted = AuthenticodeHelper.IsTrusted(updateExecutablePath);
                if (!isTrusted)
                {
                    Log.Error(@"The update file is not signed. Update will be aborted.");
                    Application.Current.Dispatcher.Invoke(() =>
                    {
                        M3L.ShowDialog(Window.GetWindow(this), M3L.GetString(M3L.string_unableToApplyUpdateNotSigned), M3L.GetString(M3L.string_errorApplyingUpdate), MessageBoxButton.OK, MessageBoxImage.Error);
                        OnClosing(DataEventArgs.Empty);
                    });
                    return;
                }
                ProgressText = M3L.GetString(M3L.string_applyingUpdate);

                string args = @"--update-boot";
                Log.Information($@"Running new mod manager in update mode: {updateExecutablePath} {args}");

                Process process = new Process();
                // Stop the process from opening a new window
                process.StartInfo.UseShellExecute = false;
                process.StartInfo.CreateNoWindow  = true;

                // Setup executable and parameters
                process.StartInfo.FileName  = updateExecutablePath;
                process.StartInfo.Arguments = args;
                process.Start();
                process.WaitForExit();

                ProgressText = M3L.GetString(M3L.string_restartingModManager);
                Thread.Sleep(2000);
                args = $"--update-from {App.BuildNumber} --update-source-path \"{updateExecutablePath}\" --update-dest-path \"{App.ExecutableLocation}\""; //Do not localize
                Log.Information($@"Running updater: {updaterExe} {args}");

                process = new Process();
                // Stop the process from opening a new window
                process.StartInfo.UseShellExecute = false;
                process.StartInfo.CreateNoWindow  = true;

                // Setup executable and parameters
                process.StartInfo.FileName  = updaterExe;
                process.StartInfo.Arguments = args;
                process.Start();
                Log.Information(@"Stopping Mod Manager to apply update");
                Log.CloseAndFlush();
                Environment.Exit(0);
            }
            else
            {
                Log.Error(@"Could not find ME3TweaksModManager.exe! Update will be aborted.");
                Application.Current.Dispatcher.Invoke(() =>
                {
                    M3L.ShowDialog(window, M3L.GetString(M3L.string_unableToApplyUpdateME3TweaksExeNotFound), M3L.GetString(M3L.string_errorApplyingUpdate), MessageBoxButton.OK, MessageBoxImage.Error);
                    OnClosing(DataEventArgs.Empty);
                });
            }
        }