void wbc_DownloadFileCompleted(object sender, AsyncCompletedEventArgs e) { try { string[] updc = System.IO.File.ReadAllLines(Application.StartupPath + @"\_temp.txt"); VersionNum = Convert.ToInt32(((string)updc.GetValue(0)).Replace(".", "")); label2.Text = "Latest Version: " + (string)updc.GetValue(0); int CurVersion = Convert.ToInt32(Application.ProductVersion.ToString().Replace(".", "")); if (updc.Length > 1) DownloadLink = (string)updc.GetValue(1); t = updc; if (CurVersion < VersionNum) { label1.Text = "A new update is available for downloading"; button1.Enabled = true; System.Windows.Forms.Timer timer1 = new System.Windows.Forms.Timer(); timer1.Interval = 20; timer1.Enabled = true; timer1.Tick += timer1_Tick; timer1.Start(); } else label1.Text = "Cheetah is up to date"; System.IO.File.Delete(Application.StartupPath + @"\_temp.txt"); } catch (Exception ex) { MessageCheetah f = new MessageCheetah(); f.Title = "Error!"; f.Message = "An error occured and the update operation could not be successfully completed. \r\n error:" + ex.Message; f.CancelVisible = false; f.ShowDialog(); } }
void downloader_DownloadFileCompleted(object sender, AsyncCompletedEventArgs e) { if (e.Cancelled == true) return; progressBar1.Value = progressBar1.MaxValue; MessageCheetah f = new MessageCheetah(); f.Title = "Warning!"; f.Message = "You now need to close Cheetah so that the update successfully completes. The Setup window will be shown to you. Follow the steps provided to complete the installation."; f.CancelVisible = false; f.ShowDialog(); Process.Start(dest); }
private void UpdaterC_Load(object sender, EventArgs e) { Opacity = 0; Timer tmr = new Timer(); tmr.Interval = 1; tmr.Tick += new EventHandler(delegate { Opacity += 0.05; if (Opacity == 1) { tmr.Stop(); tmr.Dispose(); } }); tmr.Start(); g(); label1.Text = "Current Version: " + Application.ProductVersion.ToString(); if (System.Net.NetworkInformation.NetworkInterface.GetIsNetworkAvailable()) { using (WebClient wbc = new WebClient()) { wbc.DownloadFileCompleted += new AsyncCompletedEventHandler(wbc_DownloadFileCompleted); wbc.DownloadFileAsync(new Uri("http://gt-web-software.webs.com/Cheetah.txt"), Application.StartupPath + @"\_temp.txt"); } } else { MessageCheetah f = new MessageCheetah(); f.Title = "Warning!"; f.Message = "An active network connection is required for the update operation to function. Please check your connection settings and try again."; f.CancelVisible = false; f.ShowDialog(); this.Close(); } }