c# - Loading application for Console Application -
i have application in c # , wpf application calls console application performs tasks , makes call main form. first step completed, when trying call main application, not possible.
this main application method calls console app
private void window_loaded(object sender, routedeventargs e) { var doc = new xmldocument(); doc.load("http://www.mysite.org.br/cantina/arquivoxml.xml"); if (doc.documentelement != null) { var node = doc.documentelement.selectsinglenode("/application/version"); var node1 = doc.documentelement.selectsinglenode("/application/zipfile"); if (node != null) { var version = node.innertext; var versionassembly = system.reflection.assembly.getexecutingassembly().getname().version.tostring(); if (convert.todouble(version) > convert.todouble(versionassembly)) { process.start("updater.exe"); } } } }
updater.exe load console application tasks, bears iasd.ascs.wpf.exe, , closes automatically code below.
using system.diagnostics; using ionic.zip; using system.xml; using system.io; namespace updater { public class program { private static void main() { process[] process = process.getprocessesbyname("iasd.ascs.wpf"); foreach (process proc in process) { if (!proc.hasexited) proc.kill(); } xmldocument doc = new xmldocument(); doc.load("http://www.mysite.org.br/cantina/arquivoxml.xml"); if (doc.documentelement != null) { xmlnode node1 = doc.documentelement.selectsinglenode("/application/zipfile"); if (node1 != null) { string zipfile = node1.innertext; const string end = ("http://www.mysite.org.br/cantina/"); string file = (end + zipfile); string path = system.appdomain.currentdomain.basedirectory; string path2 = (system.appdomain.currentdomain.basedirectory + @"\temp"); string path3 = system.io.path.combine(typeof(program).assembly.location, "iasd.ascs.wpf.exe"); zipfile zipfile = zipfile.read(file); { foreach (var zipentry in zipfile) { zipentry.extract(path2,extractexistingfileaction.overwritesilently); } } string dirtemp = path2; string dirinstalacao = path; string[] arquivos = directory.getfiles(path2); foreach (string item in arquivos) { string nomedoarquivo = path.getfilename(item); if (nomedoarquivo != null) { string destino = path.combine(dirinstalacao, nomedoarquivo); file.copy(item, destino, true); } } string[] arquivosapagar = directory.getfiles(path2); foreach (string item in arquivosapagar) { file.delete(item); } process.start(path3); } } const string nomeexecutavel2 = "updater.exe"; foreach (process pr2 in process.getprocessesbyname(nomeexecutavel2)) { if (!pr2.hasexited) pr2.kill(); } } } }
but did not work.
the executable not calling
now if mark paths updater code below fucniona perfectly.
using system.diagnostics; using ionic.zip; using system.xml; using system.io; namespace updater { public class program { private static void main() { process[] process = process.getprocessesbyname("iasd.ascs.wpf"); foreach (process proc in process) { if (!proc.hasexited) proc.kill(); } xmldocument doc = new xmldocument(); doc.load("http://www.escolasaps.org.br/cantina/arquivoxml.xml"); if (doc.documentelement != null) { xmlnode node1 = doc.documentelement.selectsinglenode("/application/zipfile"); if (node1 != null) { string zipfile = node1.innertext; const string end = ("http://www.escolasaps.org.br/cantina/"); string file = (end + zipfile); zipfile zipfile = zipfile.read(file); { foreach (var zipentry in zipfile) { zipentry.extract(@"c:\iasd\cantinaescolar\temp",extractexistingfileaction.overwritesilently); } } string dirtemp = @"c:\iasd\cantinaescolar\temp"; string dirinstalacao = @"c:\iasd\cantinaescolar\"; string[] arquivos = directory.getfiles(dirtemp); foreach (string item in arquivos) { string nomedoarquivo = path.getfilename(item); if (nomedoarquivo != null) { string destino = path.combine(dirinstalacao, nomedoarquivo); file.copy(item, destino, true); } } string[] arquivosapagar = directory.getfiles(dirtemp); foreach (string item in arquivosapagar) { file.delete(item); } process.start("iasd.ascs.wpf.exe"); } } const string nomeexecutavel2 = "updater.exe"; foreach (process pr2 in process.getprocessesbyname(nomeexecutavel2)) { if (!pr2.hasexited) pr2.kill(); } } } }
try this:
string path = system.io.path.combine(typeof(program).assembly.location, "myexe.exe"); using (process.start(path)) { }
Comments
Post a Comment