WebClient client = new WebClient();
Stream stream = client.OpenRead(<URL>
StreamReader reader = new StreamReader(stream);
string content = reader.ReadToEnd();
string[] vals = content.Split('\n';
//vals[0] = version
//vals[1] = download link
if (vals[0] == BotInfo.Bot_Version)
{
System.Windows.Forms.MessageBox.Show("No new updates", "Check for Updates", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Information);
return;
}
if (vals[0] != BotInfo.Bot_Version)
{
System.Windows.Forms.MessageBox.Show("New Update found! Version: " + vals[0], "Update Found", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Information);
System.Diagnostics.Process.Start(vals[1]);
}
WebClient client = new WebClient();
Stream stream = client.OpenRead(<URL>
StreamReader reader = new StreamReader(stream);
string content = reader.ReadToEnd();
string[] vals = content.Split('\n';
//vals[0] = version
//vals[1] = download link
if (vals[0] == BotInfo.Bot_Version)
{
System.Windows.Forms.MessageBox.Show("No new updates", "Check for Updates", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Information);
return;
}
if (vals[0] != BotInfo.Bot_Version)
{
System.Windows.Forms.MessageBox.Show("New Update found! Version: " + vals[0], "Update Found", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Information);
System.Diagnostics.Process.Start(vals[1]);
}
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Xml;
using System.Diagnostics;
using System.Net;
namespace Programming_NotePad
{
public partial class MainPage : DevComponents.DotNetBar.Metro.MetroForm
{
public MainPage()
{
InitializeComponent();
}
private void MainPage_Load(object sender, EventArgs e)
{
DialogResult dialog = MessageBox.Show("Hey would you like to check for updates now?", "Check for Updates", MessageBoxButtons.YesNo, MessageBoxIcon.Information);
if (dialog == DialogResult.Yes)
{
//Start update process
String downloadURL = "https://updateshost.webuda.com/Multi_Tool_Updates/File.exe";
Version newVersion = null;
String xmlUrl = "https://updateshost.webuda.com/Multi_Tool_Updates/Verify.xml";
XmlTextReader xmlReader = null;
try
{
xmlReader = new XmlTextReader(xmlUrl);
xmlReader.MoveToContent();
String elementName = "";
if ((xmlReader.NodeType == XmlNodeType.Element) && (xmlReader.Name == "updateTool"))
{
while (xmlReader.Read())
{
if (xmlReader.NodeType == XmlNodeType.Element)
{
elementName = xmlReader.Name;
}
else
{
if ((xmlReader.NodeType == XmlNodeType.Text) && (xmlReader.HasValue))
{
switch (elementName)
{
case "version": newVersion = new Version(xmlReader.Value);
break;
case "url": downloadURL = xmlReader.Value;
break;
default: MessageBox.Show("version or url not found!", "Error");
break;
}
}
}
}
}
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
finally
{
if (xmlReader != null)
xmlReader.Close();
}
Version appVersion = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version;
if (appVersion.CompareTo(newVersion) < 0)
{
DialogResult downloadRequest = MessageBox.Show(String.Format("Version {0}.{1}.{2} is now available to download.\n\nWould you like to download?", newVersion.Major, newVersion.Minor, newVersion.Build), "Update Avaialable",
MessageBoxButtons.YesNo, MessageBoxIcon.Information);
if (downloadRequest == DialogResult.Yes)
{
SaveFileDialog download = new SaveFileDialog();
download.Title = "Choose where to save the new File";
download.Filter = "Exe Files | *.exe";
if (download.ShowDialog() == DialogResult.OK)
{
WebClient download2 = new WebClient();
download2.DownloadFile(downloadURL, download.FileName);
MessageBox.Show("Download Finished! , Application now quitting so you can install your new file");
Application.Exit();
}
else
{
//do nothing
}
}
}
else
{
MessageBox.Show("This application is currently up to date!", "Update", MessageBoxButtons.OK, MessageBoxIcon.None);
}
}
else if (dialog == DialogResult.No)
{
//Cancel Dialog
}
}
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Xml;
using System.Diagnostics;
using System.Net;
namespace Programming_NotePad
{
public partial class MainPage : DevComponents.DotNetBar.Metro.MetroForm
{
public MainPage()
{
InitializeComponent();
}
private void MainPage_Load(object sender, EventArgs e)
{
DialogResult dialog = MessageBox.Show("Hey would you like to check for updates now?", "Check for Updates", MessageBoxButtons.YesNo, MessageBoxIcon.Information);
if (dialog == DialogResult.Yes)
{
//Start update process
String downloadURL = "https://updateshost.webuda.com/Multi_Tool_Updates/File.exe";
Version newVersion = null;
String xmlUrl = "https://updateshost.webuda.com/Multi_Tool_Updates/Verify.xml";
XmlTextReader xmlReader = null;
try
{
xmlReader = new XmlTextReader(xmlUrl);
xmlReader.MoveToContent();
String elementName = "";
if ((xmlReader.NodeType == XmlNodeType.Element) && (xmlReader.Name == "updateTool"))
{
while (xmlReader.Read())
{
if (xmlReader.NodeType == XmlNodeType.Element)
{
elementName = xmlReader.Name;
}
else
{
if ((xmlReader.NodeType == XmlNodeType.Text) && (xmlReader.HasValue))
{
switch (elementName)
{
case "version": newVersion = new Version(xmlReader.Value);
break;
case "url": downloadURL = xmlReader.Value;
break;
default: MessageBox.Show("version or url not found!", "Error");
break;
}
}
}
}
}
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
finally
{
if (xmlReader != null)
xmlReader.Close();
}
Version appVersion = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version;
if (appVersion.CompareTo(newVersion) < 0)
{
DialogResult downloadRequest = MessageBox.Show(String.Format("Version {0}.{1}.{2} is now available to download.\n\nWould you like to download?", newVersion.Major, newVersion.Minor, newVersion.Build), "Update Avaialable",
MessageBoxButtons.YesNo, MessageBoxIcon.Information);
if (downloadRequest == DialogResult.Yes)
{
SaveFileDialog download = new SaveFileDialog();
download.Title = "Choose where to save the new File";
download.Filter = "Exe Files | *.exe";
if (download.ShowDialog() == DialogResult.OK)
{
WebClient download2 = new WebClient();
download2.DownloadFile(downloadURL, download.FileName);
MessageBox.Show("Download Finished! , Application now quitting so you can install your new file");
Application.Exit();
}
else
{
//do nothing
}
}
}
else
{
MessageBox.Show("This application is currently up to date!", "Update", MessageBoxButtons.OK, MessageBoxIcon.None);
}
}
else if (dialog == DialogResult.No)
{
//Cancel Dialog
}
}
Copyright © 2024, NextGenUpdate.
All Rights Reserved.