/// <summary> /// checks for an update /// called on each start-up of FTPbox. /// </summary> private async Task CheckForUpdate() { #if PORTABLE try { var wc = new WebClient(); // Find out what the latest version is var latest = await wc.DownloadStringTaskAsync("http://ftpbox.org/releases/version"); var current = Application.ProductVersion; Log.Write(l.Debug, $"Current Version: {latest} Installed Version: {current}"); if (Regex.IsMatch(latest, @"([0-9]+\.){3,4}") && latest != current) { // show dialog box for download now, learn more and remind me next time var nvform = new newversion(); newversion.Newvers = latest; newversion.DownLink = current; nvform.ShowDialog(); Show(); } } catch (Exception ex) { Log.Write(l.Debug, "Error with version checking"); ex.LogException(); } #elif !DEBUG using (var updateManager = new UpdateManager("http://ftpbox.org/releases")) { var info = await updateManager.CheckForUpdate(); if (info.CurrentlyInstalledVersion == null || info.FutureReleaseEntry == null) { return; } Log.Write(l.Debug, $"Current Version: {info.CurrentlyInstalledVersion.Version} Installed Version: {info.FutureReleaseEntry.Version}"); if (info.FutureReleaseEntry.Version > info.CurrentlyInstalledVersion.Version) { // show dialog box for download now, learn more and remind me next time var nvform = new newversion(); newversion.Newvers = info.CurrentlyInstalledVersion.Version.ToString(); newversion.DownLink = info.FutureReleaseEntry.Version.ToString(); nvform.ShowDialog(); if (newversion.update) { await updateManager.UpdateApp(); } } } #endif }
/// <summary> /// checks for an update /// called on each start-up of FTPbox. /// </summary> private void CheckForUpdate() { try { var wc = new WebClient(); wc.DownloadStringCompleted += (o, e) => { if (e.Cancelled || e.Error != null) { return; } var json = (Dictionary <string, string>) JsonConvert.DeserializeObject(e.Result, typeof(Dictionary <string, string>)); var version = json["NewVersion"]; // Check that the downloaded file has the correct version format, using regex. if (Regex.IsMatch(version, @"[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+")) { Log.Write(l.Debug, "Current Version: {0} Installed Version: {1}", version, Application.ProductVersion); if (version == Application.ProductVersion) { return; } // show dialog box for download now, learn more and remind me next time var nvform = new newversion { Tag = this }; newversion.Newvers = json["NewVersion"]; newversion.DownLink = json["DownloadLink"]; nvform.ShowDialog(); Show(); } }; // Find out what the latest version is wc.DownloadStringAsync(new Uri(@"http://ftpbox.org/winversion.json")); } catch (Exception ex) { Log.Write(l.Debug, "Error with version checking"); ex.LogException(); } }
private void DownloadVersionFileComplete(object sender, AsyncCompletedEventArgs e) { string path = Path.Combine(Profile.AppdataFolder, "latestversion.txt"); if (!File.Exists(path)) return; string version = File.ReadAllText(path); if (version.Length == 7) { Log.Write(l.Debug, "Current Version: {0} Installed Version: {1}", version, Application.ProductVersion); if (version != Application.ProductVersion) { newversion nvform = new newversion(version); nvform.Tag = this; nvform.ShowDialog(); this.Show(); // show dialog box for download now, learn more and remind me next time } } }
/// <summary> /// checks for an update /// called on each start-up of FTPbox. /// </summary> private void CheckForUpdate() { try { var wc = new WebClient(); wc.DownloadStringCompleted += (o, e) => { if (e.Cancelled || e.Error != null) return; var json = (Dictionary<string, string>) JsonConvert.DeserializeObject(e.Result, typeof (Dictionary<string, string>)); var version = json["NewVersion"]; // Check that the downloaded file has the correct version format, using regex. if (Regex.IsMatch(version, @"[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+")) { Log.Write(l.Debug, "Current Version: {0} Installed Version: {1}", version, Application.ProductVersion); if (version == Application.ProductVersion) return; // show dialog box for download now, learn more and remind me next time var nvform = new newversion {Tag = this}; newversion.Newvers = json["NewVersion"]; newversion.DownLink = json["DownloadLink"]; nvform.ShowDialog(); Show(); } }; // Find out what the latest version is wc.DownloadStringAsync(new Uri(@"http://ftpbox.org/winversion.json")); } catch (Exception ex) { Log.Write(l.Debug, "Error with version checking"); Common.LogError(ex); } }
private void browser_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e) { try { string version = br.Document.Body.InnerText; Log.Write(l.Debug, "Current Version: {0} Installed Version: {1}", version, Application.ProductVersion); if (version != Application.ProductVersion) { newversion nvform = new newversion(version); nvform.Tag = this; nvform.ShowDialog(); this.Show(); // show dialog box for download now, learn more and remind me next time } } catch { Log.Write(l.Error, "Server down"); } }