BF2Statistics.ProgramUpdater.Wc_DownloadFileCompleted C# (CSharp) Метод

Wc_DownloadFileCompleted() приватный статический Метод

Event called when an update file has completed its download
private static Wc_DownloadFileCompleted ( object sender, AsyncCompletedEventArgs e ) : void
sender object
e System.ComponentModel.AsyncCompletedEventArgs
Результат void
        private static void Wc_DownloadFileCompleted(object sender, AsyncCompletedEventArgs e)
        {
            // Close task form, and unregister for updates
            TaskForm.Cancelled -= TaskForm_Cancelled;
            TaskForm.CloseForm();
            IsDownloading = false;

            // Dispose webclient
            Web.Dispose();

            // If we cancelled, stop here
            if (e.Cancelled)
            {
                // Delete junk files
                if (File.Exists(UpdateFileLocation))
                    File.Delete(UpdateFileLocation);

                return;
            }

            // Try to start the isntaller
            try
            {
                // Extract setup.exe
                string exFile = Path.Combine(Paths.DocumentsFolder, "setup.exe");
                using (ZipArchive file = ZipFile.Open(UpdateFileLocation, ZipArchiveMode.Read))
                {
                    ZipArchiveEntry setupFile = file.Entries.FirstOrDefault(x => x.FullName == "setup.exe");
                    if (setupFile != null)
                    {
                        // Extract and start the new update installer
                        setupFile.ExtractToFile(exFile, true);
                        Process installer = Process.Start(exFile);
                        installer.WaitForInputIdle();
                    }
                    else
                    {
                        MessageBox.Show(
                            "The Setup.exe file appears to be missing from the update archive! You will need to manually apply the update.",
                            "Installation Error",
                            MessageBoxButtons.OK,
                            MessageBoxIcon.Error
                        );
                    }
                }
            }
            catch(Exception Ex)
            {
                MessageBox.Show(
                    "An Occured while trying to install the new update. You will need to manually apply the update."
                    + Environment.NewLine.Repeat(1) + "Error Message: " + Ex.Message,
                    "Installation Error",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Error
                );
                ExceptionHandler.GenerateExceptionLog(Ex);
            }

            // Exit the application
            Application.Exit();
        }
    }