c# - How to create auto update? -


ok have searched , cannot find im looking for. right need how exe download current folder in , when need switch out old update, overwrite or something. want when click check update button checks see if there update, if there says download yes or no , click yes downloads current folder in , overwrites old update new update. , if there isnt update says have current version. im using xml file has version , download located on website btw.

this have,

private void checkforupdatesbutton_click(object sender, eventargs e) {     string downloadurl = "";     version newversion = null;     string aboutupdate = "";     string xmlurl = "";     xmltextreader reader = null;     try     {         reader = new xmltextreader(xmlurl);         reader.movetocontent();         string elementname = "";         if ((reader.nodetype == xmlnodetype.element) && (reader.name == "appinfo"))         {             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":                                 downloadurl = reader.value;                                 break;                             case "about":                                 aboutupdate = reader.value;                                 break;                         }                 }             }         }     }     catch (exception ex)     {         messagebox.show(ex.message);         environment.exit(1);     }         {         if (reader != null)             reader.close();     }     version applicationversion = system.reflection.assembly.getexecutingassembly().getname().version;     if (applicationversion.compareto(newversion) < 0)     {         string str = string.format("new version found!\nyour version: {0}.\nnewest version: {1}. \nadded in version: {2}. ", applicationversion, newversion, aboutupdate);         if (dialogresult.no != messagebox.show(str + "\ndo want download ?", "update", messageboxbuttons.yesno, messageboxicon.question))         {             try             {                 webclient webclient = new webclient();                 webclient.downloadfile("", "");             }             catch             {             }             return;         }         else         {             ;         }     }     else     {         messagebox.show("looks have current update " + applicationversion + "!", "update", messageboxbuttons.ok, messageboxicon.none);     } } 

if can please do, have searched , tried everything, thank .

my suggestion: don't reinvent wheel. ms provides built-in functionality/project types auto-updating applications. called clickonce. here's link started: clickonce deployment

if using latest versions of vs , .net, have other choices, such web or cloud (azure) based deployment.

here's more comprehensive deployment page: deploying applications, services, , components


Comments

Popular posts from this blog

how to proxy from https to http with lighttpd -

android - Automated my builds -

python - Flask migration error -