void downloader_DownloadFileCompleted(object sender, AsyncCompletedEventArgs e) { string[] us = (string[])e.UserState; string currentVersion = us[0]; string downloadToPath = us[1]; string executeTarget = us[2]; if (!downloadToPath.EndsWith("\\")) { downloadToPath += "\\"; } // Download folder + zip file string zipName = downloadToPath + currentVersion + ".zip"; // Download folder\version\ + executable string exePath = downloadToPath + currentVersion + "\\" + executeTarget; if (new FileInfo(zipName).Exists) { using (Ionic.Zip.ZipFile zip = new Ionic.Zip.ZipFile(zipName)) { if (TextVer == "app.version") { if (File.Exists(Environment.CurrentDirectory + "/Launcher.bak")) { File.Delete(Environment.CurrentDirectory + "/Launcher.bak"); } File.Move(AppDomain.CurrentDomain.FriendlyName, "Launcher.bak"); Thread.Sleep(5000); zip.ExtractAll(downloadToPath, Ionic.Zip.ExtractExistingFileAction.OverwriteSilently); MessageBoxResult result = System.Windows.MessageBox.Show("Launcher updated, restart app!", "Congratulations", MessageBoxButton.OK, MessageBoxImage.Question); if (result == MessageBoxResult.OK) { Process proc = Process.Start(downloadToPath + "\\" + executeTarget); Environment.Exit(0); } } else { zip.ExtractAll(downloadToPath + currentVersion, Ionic.Zip.ExtractExistingFileAction.OverwriteSilently); } } if (new FileInfo(exePath).Exists) { Versions.CreateLocalVersionFile(downloadToPath, TextVer, currentVersion); Process proc = Process.Start(exePath); } else { System.Windows.MessageBox.Show("Problem with download. File does not exist."); } } else { System.Windows.MessageBox.Show("Problem with download. File does not exist."); } }
void downloader_DownloadFileCompleted(object sender, System.ComponentModel.AsyncCompletedEventArgs e) { string[] us = (string[])e.UserState; string currentVersion = us[0]; string downloadPath = us[1]; string executeTarget = us[2]; string localVersion = us[3]; if (!downloadPath.EndsWith("\\")) // Give a trailing \ if there isn't one { downloadPath += "\\"; } string zipName = downloadPath + currentVersion + ".zip"; // Download folder + zip file string sourcePath = downloadPath + currentVersion; // Download Path string targetPath = CommConst.executePath; // 실행폴더 string exePath = targetPath + executeTarget; // Download folder\version\ + executable if (new FileInfo(zipName).Exists) { using (Ionic.Zip.ZipFile zip = new Ionic.Zip.ZipFile(zipName)) { zip.ExtractAll(downloadPath + currentVersion, Ionic.Zip.ExtractExistingFileAction.OverwriteSilently); } CopyFolder(sourcePath, targetPath); if (new FileInfo(exePath).Exists) { Versions.CreateLocalVersionFile(downloadPath, localVersion, currentVersion); // 집진기 Controller 종료 Process[] psList = Process.GetProcessesByName("CADC"); if (psList.Length > 0) { psList[0].Kill(); } //MessageBox.Show("Path : " + exePath); Process.Start(exePath); Close(); } else { //Debug.Write("Problem with download. File does not exist."); MessageBox.Show("Problem with download. File does not exist.", "Updater"); } } else { //Debug.Write("Problem with download. File does not exist."); MessageBox.Show("Problem with download. File does not exist.", "Updater"); } }