private void tmrCheckForUpdate_Tick(object sender, EventArgs e) { tmrCheckForUpdate.Stop(); _NewVersionAvailable = AutoUpdate.Available(new Uri("http://www.randm.ca/autoupdate.ini")); if (_NewVersionAvailable) { Logging.instance.LogMessage("A new version is available at http://www.randm.ca/pddns/"); } else { // Only restart the timer if there isn't a new version found yet tmrCheckForUpdate.Interval = 1 * 24 * 60 * 60 * 1000; // 1 day tmrCheckForUpdate.Start(); } }
static public bool Update(Uri url, bool displayNoUpdateMessage) { if (AutoUpdate.Available(url)) { if (Dialog.YesNo("A new version of " + ProcessUtils.ProductName + " is available!" + Environment.NewLine + Environment.NewLine + "Your version: " + ProcessUtils.ProductVersion + Environment.NewLine + "New version: " + AutoUpdate.Version + Environment.NewLine + Environment.NewLine + AutoUpdate.Comments + Environment.NewLine + Environment.NewLine + "Do you want to download and install the newest version?" + Environment.NewLine + "(Doing so will close " + ProcessUtils.ProductName + ")", "New Version Available!") == DialogResult.Yes) { string DownloadFile = StringUtils.PathCombine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), Application.CompanyName, Path.GetFileName(AutoUpdate.Url.ToString())); using (frmRMFileDownloader FD = new frmRMFileDownloader(new Uri(AutoUpdate.Url), DownloadFile)) { if (FD.ShowDialog() == DialogResult.OK) { try { // Launch installer and return Process.Start(DownloadFile); return(true); } catch (Exception) { // User didn't allow the installer to run, so don't quit Dialog.Error("Unable to launch installer", "Error Updating"); // Clean up the failed installer FileUtils.FileDelete(DownloadFile); } } } } } else if (displayNoUpdateMessage) { Dialog.Information("You've got the latest and greatest!", "No Update Available"); } return(false); }