C# update - code reading/xml reader -
what add if there no update available message box pops saying no update? although easy fix, i've been working on lot of updating systems lately, i'm stumped on it.
version newversion = null; string url = ""; xmltextreader reader = null; try { string xmlurl = "url"; reader = new xmltextreader(xmlurl); reader.movetocontent(); string elementname = ""; if ((reader.nodetype == xmlnodetype.element) && (reader.name == "app")) { 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 { } { if (reader != null) reader.close(); } version curversion = system.reflection.assembly.getexecutingassembly().getname().version; if (curversion.compareto(newversion) < 0) { string title = "new update avaliable"; string question = "download now?"; if (dialogresult.yes == messageboxex.show(this, question, title, messageboxbuttons.yesno, messageboxicon.question)) { process.start(url); } }
is wrong comparing curversion
newversion
?
if (curversion == newversion) { messagebox.show("no update needed"); } else if (curversion.compareto(newversion) < 0) { string title = "new update avaliable"; string question = "download now?"; if (dialogresult.yes == messageboxex.show(this, question, title, messageboxbuttons.yesno, messageboxicon.question)) { process.start(url); } }
Comments
Post a Comment