Advertisement
Guest User

Untitled

a guest
Apr 18th, 2014
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.49 KB | None | 0 0
  1. private void Window_Loaded(object sender, RoutedEventArgs e)
  2. {
  3.  
  4. var doc = new XmlDocument();
  5. doc.Load("http://www.mysite.org.br/Cantina/arquivoXML.xml");
  6. if (doc.DocumentElement != null)
  7. {
  8. var node = doc.DocumentElement.SelectSingleNode("/Application/Version");
  9. var node1 = doc.DocumentElement.SelectSingleNode("/Application/ZipFile");
  10. if (node != null)
  11. {
  12. var version = node.InnerText;
  13. var versionAssembly = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString();
  14. if (Convert.ToDouble(version) > Convert.ToDouble(versionAssembly))
  15. {
  16. Process.Start("Updater.exe");
  17. }
  18. }
  19. }
  20. }
  21.  
  22. using System.Diagnostics;
  23. using Ionic.Zip;
  24. using System.Xml;
  25. using System.IO;
  26.  
  27.  
  28. namespace Updater
  29. {
  30. public class Program
  31. {
  32. private static void Main()
  33. {
  34. Process[] process = Process.GetProcessesByName("IASD.ASCS.WPF");
  35. foreach (Process proc in process)
  36. {
  37. if (!proc.HasExited)
  38. proc.Kill();
  39. }
  40. XmlDocument doc = new XmlDocument();
  41. doc.Load("http://www.mysite.org.br/Cantina/arquivoXML.xml");
  42. if (doc.DocumentElement != null)
  43. {
  44. XmlNode node1 = doc.DocumentElement.SelectSingleNode("/Application/ZipFile");
  45. if (node1 != null)
  46. {
  47. string zipfile = node1.InnerText;
  48. const string end = ("http://www.mysite.org.br/Cantina/");
  49. string file = (end + zipfile);
  50. string path = System.AppDomain.CurrentDomain.BaseDirectory;
  51. string path2 = (System.AppDomain.CurrentDomain.BaseDirectory + @"Temp");
  52. string path3 = System.IO.Path.Combine(typeof(Program).Assembly.Location, "IASD.ASCS.WPF.exe");
  53. ZipFile zipFile = ZipFile.Read(file);
  54. {
  55. foreach (var zipEntry in zipFile)
  56. {
  57. zipEntry.Extract(path2,ExtractExistingFileAction.OverwriteSilently);
  58. }
  59. }
  60. string dirTemp = path2;
  61. string dirInstalacao = path;
  62. string[] arquivos = Directory.GetFiles(path2);
  63. foreach (string item in arquivos)
  64. {
  65. string nomedoarquivo = Path.GetFileName(item);
  66. if (nomedoarquivo != null)
  67. {
  68. string destino = Path.Combine(dirInstalacao, nomedoarquivo);
  69. File.Copy(item, destino, true);
  70. }
  71. }
  72. string[] arquivosApagar = Directory.GetFiles(path2);
  73. foreach (string item in arquivosApagar)
  74. {
  75. File.Delete(item);
  76. }
  77. Process.Start(path3);
  78. }
  79. }
  80. const string nomeExecutavel2 = "Updater.exe";
  81. foreach (Process pr2 in Process.GetProcessesByName(nomeExecutavel2))
  82. {
  83. if (!pr2.HasExited) pr2.Kill();
  84. }
  85. }
  86. }
  87. }
  88.  
  89. using System.Diagnostics;
  90. using Ionic.Zip;
  91. using System.Xml;
  92. using System.IO;
  93.  
  94.  
  95. namespace Updater
  96. {
  97. public class Program
  98. {
  99. private static void Main()
  100. {
  101. Process[] process = Process.GetProcessesByName("IASD.ASCS.WPF");
  102. foreach (Process proc in process)
  103. {
  104. if (!proc.HasExited)
  105. proc.Kill();
  106. }
  107. XmlDocument doc = new XmlDocument();
  108. doc.Load("http://www.escolasaps.org.br/Cantina/arquivoXML.xml");
  109. if (doc.DocumentElement != null)
  110. {
  111. XmlNode node1 = doc.DocumentElement.SelectSingleNode("/Application/ZipFile");
  112. if (node1 != null)
  113. {
  114. string zipfile = node1.InnerText;
  115. const string end = ("http://www.escolasaps.org.br/Cantina/");
  116. string file = (end + zipfile);
  117. ZipFile zipFile = ZipFile.Read(file);
  118. {
  119. foreach (var zipEntry in zipFile)
  120. {
  121. zipEntry.Extract(@"c:IASDCantinaEscolarTemp",ExtractExistingFileAction.OverwriteSilently);
  122. }
  123. }
  124. string dirTemp = @"c:IASDCantinaEscolarTemp";
  125. string dirInstalacao = @"c:IASDCantinaEscolar";
  126. string[] arquivos = Directory.GetFiles(dirTemp);
  127. foreach (string item in arquivos)
  128. {
  129. string nomedoarquivo = Path.GetFileName(item);
  130. if (nomedoarquivo != null)
  131. {
  132. string destino = Path.Combine(dirInstalacao, nomedoarquivo);
  133. File.Copy(item, destino, true);
  134. }
  135. }
  136. string[] arquivosApagar = Directory.GetFiles(dirTemp);
  137. foreach (string item in arquivosApagar)
  138. {
  139. File.Delete(item);
  140. }
  141. Process.Start("IASD.ASCS.WPF.exe");
  142. }
  143. }
  144. const string nomeExecutavel2 = "Updater.exe";
  145. foreach (Process pr2 in Process.GetProcessesByName(nomeExecutavel2))
  146. {
  147. if (!pr2.HasExited) pr2.Kill();
  148. }
  149. }
  150. }
  151. }
  152.  
  153. string path = System.IO.Path.Combine(typeof(Program).Assembly.Location, "MyExe.exe");
  154. using (Process.Start(path))
  155. {
  156. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement