SHARE
TWEET

Reading version on Weebly

capasha Feb 28th, 2016 (edited) 103 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using System.Net;
  2. using System.Text.RegularExpressions;
  3. using System.Diagnostics;
  4.  
  5.         private void updateChecking()
  6.         {
  7.             WebClient wb = new WebClient();
  8.             Match match;
  9.             string data = wb.DownloadString("http://eebuilder.weebly.com/botversion.html");
  10.             string[] data1 = data.Split('\n');
  11.             string versionLine = null;
  12.             int clientVersion = Convert.ToInt32(this.ProductVersion.Replace(".", string.Empty));
  13.             for (int i = 0; i < data1.Length; i++)
  14.             {
  15.                 if (data1[i].Contains("<meta property=\"og:description\" content=\""))
  16.                 {
  17.                     versionLine = data1[i].ToString();
  18.                     break;
  19.                 }
  20.             }
  21.             if (versionLine != null) {
  22.                 match = Regex.Match(versionLine,@"[0-9]{0,32}\.[0-9]{0,32}");
  23.                 if (match.Success)
  24.                 {
  25.                     var siteVersion = Convert.ToInt32(match.Value.ToString().Replace(".", string.Empty));
  26.                     if (siteVersion > clientVersion)
  27.                     {
  28.                         DialogResult dr = MessageBox.Show("Do you want to download the newest version?", "Info", MessageBoxButtons.YesNo);
  29.                         if (dr == DialogResult.Yes)
  30.                         {
  31.                             Process.Start("http://eebuilder.weebly.com/botversion.html");
  32.                         }
  33.                     }
  34.                     else
  35.                     {
  36.                         Console.WriteLine("You have the latest update");
  37.                     }
  38.                    
  39.                 }
  40.             }
  41.             else
  42.             {
  43.                 Console.WriteLine("Couldn't find the version information.");
  44.             }
  45.  
  46.         }
  47. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top