Beispiel #1
0
        // Start the updater
        public static void Update()
        {
            Thread Update = new Thread(() =>
            {
                // Odd bug, if i don't wait a second then the updater won't get extracted.
                Thread.Sleep(1500);

                Stream output = File.OpenWrite(Path.Combine(Environment.CurrentDirectory, Statics.UpdaterName));
                output.Write(Meldii.Properties.Resources.Meldii_Updater, 0, Meldii.Properties.Resources.Meldii_Updater.Length);
                output.Flush();
                output.Close();

                using (WebClient Client = new WebClient())
                {
                    Client.DownloadFile(Statics.UpdateExeUrl, "Meldii_New.exe");
                }

                Process.Start(Statics.UpdaterName);

                App.Current.Dispatcher.Invoke((Action) delegate()
                {
                    Application.Current.Shutdown();
                });
            });

            Update.IsBackground = true;
            Update.Start();

            MainWindow.ShowUpdateProgress();
        }
Beispiel #2
0
        // Start the updater
        public static void Update()
        {
            Thread Update = new Thread(() =>
            {
                // Extract the updater.
                Stream output = File.OpenWrite(Path.Combine(Environment.CurrentDirectory, Statics.UpdaterName));
                output.Write(Meldii.Properties.Resources.Meldii_Updater, 0, Meldii.Properties.Resources.Meldii_Updater.Length);
                output.Flush();
                output.Close();

                // Check if we have dirty files to delete.
                if (File.Exists("Meldii_DL.exe"))
                {
                    File.Delete("Meldii_DL.exe");
                }
                if (File.Exists("Meldii_New.exe"))
                {
                    File.Delete("Meldii_New.exe");
                }

                // Download our new version of Meldii.
                using (WebClient Client = new WebClient())
                {
                    Client.DownloadFile(Statics.UpdateExeUrl, "Meldii_DL.exe");
                }

                // The download completed, rename the file and start the update.
                File.Move("Meldii_DL.exe", "Meldii_New.exe");
                Process.Start(Statics.UpdaterName);

                // Close the app.
                App.Current.Dispatcher.Invoke((Action) delegate()
                {
                    Application.Current.Shutdown();
                });
            });

            Update.IsBackground = true;
            Update.Start();

            MainWindow.ShowUpdateProgress();
        }