minicl55

Untitled

Mar 30th, 2014
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.58 KB | None | 0 0
  1. string word = "1.2.0";
  2. try
  3.             {
  4.                 HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create("URL for version");
  5.                 HttpWebResponse response = (HttpWebResponse)request.GetResponse();
  6.                 StreamReader reader = new StreamReader(response.GetResponseStream());
  7.                 string result = reader.ReadToEnd();
  8.                 if (result == word)
  9.                 {
  10.                     downloadUpdate.Text = "No updates";
  11.                     Text = Text + word;
  12.                 }
  13.                 else
  14.                 {
  15.                     downloadUpdate.Enabled = true;
  16.                     Text = "Text " + word + " (version " + result + " avaible)";
  17.                     var dl = MessageBox.Show("There is an update! Would you like to download now?\n\nThe newest version is "+ result + " and you are running " + word + ".", "Text", MessageBoxButtons.YesNo, MessageBoxIcon.Information);
  18.                     if (dl == DialogResult.Yes)
  19.                     {
  20.                         string url = "URL for updater file";
  21.                         var web = new WebBrowser();
  22.                         web.Navigate(url);
  23.                     }
  24.                 }
  25.             }
  26.             catch
  27.             {
  28.                 var failed = MessageBox.Show("It appears you don't have internet access. As such the update checker failed.", "Text", MessageBoxButtons.RetryCancel, MessageBoxIcon.Error);
  29.                 if (failed == DialogResult.Retry)
  30.                 {
  31.                     Form1_Load("", EventArgs.Empty);
  32.                 }
  33.             }
Advertisement
Add Comment
Please, Sign In to add comment