Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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");
- }
- }
- }
- }
- 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();
- }
- }
- }
- }
- 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:IASDCantinaEscolarTemp",ExtractExistingFileAction.OverwriteSilently);
- }
- }
- string dirTemp = @"c:IASDCantinaEscolarTemp";
- string dirInstalacao = @"c:IASDCantinaEscolar";
- 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();
- }
- }
- }
- }
- string path = System.IO.Path.Combine(typeof(Program).Assembly.Location, "MyExe.exe");
- using (Process.Start(path))
- {
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement