Ejemplo n.º 1
0
        private void Updater_Load(object sender, System.EventArgs e)
        {
            if (File.Exists("New_unrar.dll")) {
                File.Copy("New_unrar.dll", "unrar.dll", true);
                File.Delete("New_unrar.dll");
            }

            closeTimer.Stop();

            if (UpdaterMain.UpdateVersion == null)
            {
                UpdateStatus("Checking latest version...");

                try
                {
                    HttpWebRequest req = (HttpWebRequest)WebRequest.Create("http://razor.uo.cx/version.txt");
                    req.UserAgent = "Razor Updater";

                    using (StreamReader reader = new StreamReader(req.GetResponse().GetResponseStream()))
                    {
                        UpdaterMain.UpdateVersion = new Version(reader.ReadToEnd().Trim());
                    }
                }
                catch { UpdateFailed(); return; }
            }

            _Downloader = new Downloader( String.Format("https://github.com/msturgill/razor/releases/download/v{0}/Update.rar", UpdaterMain.UpdateVersion.ToString()), "Update.rar",
                ChangelogRAR,
                new ProgressChange( OnProgressChange ), new ConnectionFailed( OnConnectionFailed ), new OperationComplete( OnDownloadComplete ),
                new MessageDownloaded( OnChangelogDownloaded ) );

            UpdateStatus( "Downloading changelog..." );
            _Downloader.Download();

            txtChangeLog.Text = "(Fetching Changelog...)";
            txtChangeLog.Focus();
            txtChangeLog.Select( 0, 0 );
        }