public bool IsUpdateAvailable(string CurrentVersion) { if (!EnableUpdates) { return(false); } string ReleasePageAddress = "https://github.com/dlebansais/PgMessenger/releases"; try { ServicePointManager.Expect100Continue = true; ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; HttpWebRequest Request = WebRequest.Create(ReleasePageAddress) as HttpWebRequest; using (WebResponse Response = Request.GetResponse()) { using (Stream ResponseStream = Response.GetResponseStream()) { using (StreamReader Reader = new StreamReader(ResponseStream, Encoding.ASCII)) { string Content = Reader.ReadToEnd(); string Pattern = @"<a href=""/dlebansais/PgMessenger/releases/tag/"; int Index = Content.IndexOf(Pattern); if (Index >= 0) { string UpdateTagVersion = Content.Substring(Index + Pattern.Length, 20); int EndIndex = UpdateTagVersion.IndexOf('"'); if (EndIndex > 0) { UpdateTagVersion = UpdateTagVersion.Substring(0, EndIndex); string UpdateVersion; if (UpdateTagVersion.ToLower().StartsWith("v")) { UpdateVersion = UpdateTagVersion.Substring(1); } else { UpdateVersion = UpdateTagVersion; } string[] UpdateSplit = UpdateVersion.Split('.'); string[] CurrentSplit = CurrentVersion.Split('.'); for (int i = 0; i < UpdateSplit.Length && i < CurrentSplit.Length; i++) { int UpdateValue, CurrentValue; if (!int.TryParse(UpdateSplit[i], out UpdateValue) || !int.TryParse(CurrentSplit[i], out CurrentValue)) { break; } else if (UpdateValue < CurrentValue) { break; } else if (UpdateValue > CurrentValue) { UpdateLink = "https://github.com/dlebansais/PgMessenger/releases/download/" + UpdateTagVersion + "/PgMessenger.exe"; break; } } } } } } } } catch (Exception e) { Debug.Print(e.Message); } return(UpdateLink != null); }