private void checkForUpdateToolStripMenuItem_Click(object sender, EventArgs e)
{
this.Cursor = Cursors.WaitCursor;
Version newVersion = null;
XmlTextReader reader = null;
string url = null;
try
{
string xmlURL = "https://dl.dropbox.com/u/24219056/BSPVersion.xml";
reader = new XmlTextReader(xmlURL);
reader.MoveToContent();
string elementName = "";
if ((reader.NodeType == XmlNodeType.Element) &&
(reader.Name == "battlescriptpro"))
{
while (reader.Read())
{
if (reader.NodeType == XmlNodeType.Element)
{
elementName = reader.Name;
}
else
{
if ((reader.NodeType == XmlNodeType.Text) && (reader.HasValue))
{
switch (elementName)
{
case "version":
newVersion = new Version(reader.Value);
break;
case "url":
url = reader.Value;
break;
}
}
}
}
}
}
catch (Exception)
{
}
finally
{
if (reader != null)
{
reader.Close();
}
}
this.Cursor = Cursors.Default;
Version curVersion = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version;
if (curVersion.CompareTo(newVersion) < 0)
{
if (DialogResult.Yes == MessageBox.Show(this, "Download the new version?", "New Version Detected",
MessageBoxButtons.YesNo,
MessageBoxIcon.Question))
{
System.Diagnostics.Process.Start(url);
}
}
else
{
MessageBox.Show("Could not find newer version");
}
}