Basically in this code I'm checking if the xyz(dotcom)/update.xml has a new version available, if the new version is available it will download from the website. It was working for first time, now everytime I check for update, it directly just sent to "Application is Up-to-Date" code despite there is a new version available in xml file, I believe my program is not getting new updated xml file from the link, what could be the issue? please check code below.**** If you need more information, please let me know.
public void checkForUpdate()
{
string download_url = "";
Version newVersion = null;
string xmlurl = "http://xyz.(dotcom)/update.xml";
try
{
XmlTextReader reader = new XmlTextReader(xmlurl);
reader.MoveToContent();
string elementname = "";
if ((reader.NodeType == XmlNodeType.Element) && (reader.Name == "XYZ"))
{
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":
download_url = reader.Value;
break;
}
}
}
}
}
}
catch (Exception ex) { MessageBox.Show(ex.Message.ToString(), "Exception", MessageBoxButtons.OK, MessageBoxIcon.Warning); }
finally
{
if (reader != null)
{
reader.Close();
}
Version Applicationversion = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version;
if (Applicationversion.CompareTo(newVersion) < 0)
{
DialogResult dialogresult = (MessageBox.Show("New Version: " + newVersion + " is available to download, would you like to download now?", "New Version Available", MessageBoxButtons.YesNo, MessageBoxIcon.Information));
{
if (dialogresult == DialogResult.Yes)
{
//System.Diagnostics.Process.Start(link);
Download dw = new Download();
dw.ShowDialog();
}
else if (dialogresult == DialogResult.No)
{
}
}
}
else
{
MessageBox.Show("Your application is up-to-date!", "Up-to-Date!", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
}
}