public void CheckForNewVersion() { Stream s; TransferManager tm = new TransferManager(); if (tm.downloadFile(URL, out s, updateFilePath, null)) { s.Close(); this.showUpdateDialog(s); this.cleanup(); } }
private void performUpdate(object obj) { string url = (string)zipFileURL; String fullAppName = callingAssembly.GetName().CodeBase; String appPath = Path.GetDirectoryName(fullAppName); String updateDir = appPath + "\\" + UPDATE_FOLDER_NAME; String updateFilename = getFilename(url); string updateZip = updateDir + "\\" + updateFilename; // Create directory to store update files Directory.CreateDirectory(updateDir); TransferManager tm = new TransferManager(); tm.AddObserver(notification); Stream s; tm.downloadFile(url, out s, updateZip, notification.trans); if (s != null) { s.Close(); } if (!abortUpdate) { using (ZipFile zip1 = ZipFile.Read(updateZip)) { foreach (ZipEntry e in zip1) { e.Extract(updateDir, ExtractExistingFileAction.OverwriteSilently); } } File.Delete(updateZip); string backupDir = appPath + "\\" + BACKUP_FOLDER_NAME; if (Directory.Exists(backupDir)) { Directory.Delete(backupDir, true); } Directory.CreateDirectory(backupDir); foreach (string filepath in Directory.GetFiles(updateDir)) { string originalFile = appPath + "\\" + getFilenameFromPath(filepath); if (File.Exists(originalFile)) { string backupFilepath = backupDir + "\\" + getFilenameFromPath(filepath); File.Move(originalFile, backupFilepath); File.Move(filepath, originalFile); } } OnUpdateDone(); } }
private void performUpdate(object obj) { string url = (string)zipFileURL; String fullAppName = callingAssembly.GetName().CodeBase; String appPath = Path.GetDirectoryName(fullAppName); String updateDir = appPath + "\\" + UPDATE_FOLDER_NAME; String updateFilename = getFilename(url); string updateZip = updateDir + "\\" + updateFilename; // Create directory to store update files Directory.CreateDirectory(updateDir); TransferManager tm = new TransferManager(); tm.AddObserver(notification); Stream s; tm.downloadFile(url, out s, updateZip, notification.trans); if (s != null) s.Close(); if (!abortUpdate) { using (ZipFile zip1 = ZipFile.Read(updateZip)) { foreach (ZipEntry e in zip1) { e.Extract(updateDir, ExtractExistingFileAction.OverwriteSilently); } } File.Delete(updateZip); string backupDir = appPath + "\\" + BACKUP_FOLDER_NAME; if (Directory.Exists(backupDir)) Directory.Delete(backupDir, true); Directory.CreateDirectory(backupDir); foreach (string filepath in Directory.GetFiles(updateDir)) { string originalFile = appPath + "\\" + getFilenameFromPath(filepath); if (File.Exists(originalFile)) { string backupFilepath = backupDir + "\\" + getFilenameFromPath(filepath); File.Move(originalFile, backupFilepath); File.Move(filepath, originalFile); } } OnUpdateDone(); } }
public int CheckForNewVersion() { Stream s; TransferManager tm = new TransferManager(); try{ if (tm.downloadFile(URL, out s, updateFilePath, null)) { s.Close(); var result = this.showUpdateDialog(s); this.cleanup(); return result; } }catch(Exception e){ Logger.Instance.log("CheckForNewVersion failed: " + e.Message); } return RESULT_ERROR; }