private FileInfo DownloadUpdateInstaller() { curDownloadingStatus = UpdateStatus.DownloadingInstaller; RaiseUpdateStatusChanged(curDownloadingStatus); // Ensure update installer path is empty var installerDirPath = new DirectoryInfo(Path.Combine(MyPaths.GetMyAppDataPath(), "UpdateInstallerTool")); if (installerDirPath.Exists) { installerDirPath.Delete(true); } Task.Delay(100); installerDirPath.Create(); Task.Delay(100); // Download update installer zip string installerZipPath = Path.Combine(installerDirPath.FullName, "UpdatenInstaller.zip"); WebClient.DownloadFile(UpdateInfo.UpdateInstallerLink, installerZipPath); // Extract update installer var installerExtractPath = installerDirPath.CreateSubdirectory("extracted"); ZipFile.ExtractToDirectory(installerZipPath, installerExtractPath.FullName); File.Delete(installerZipPath); // Get UpdateInstaller.exe file return(installerExtractPath.EnumerateFiles("*.exe").FirstOrDefault()); }
public bool DownloadPackage(UpdatePackageInfo package) { curDownloadingStatus = UpdateStatus.DownloadingPackage; RaiseUpdateStatusChanged(curDownloadingStatus); string dirPath = Path.Combine(MyPaths.GetMyAppDataPath(), Conversions.ToString(package.GetHashCode())); string zipPath = Path.Combine(dirPath, PackageFileNameDefinations.ZIP_PACKAGE_FILENAME); var dir = new DirectoryInfo(dirPath); try { // Ensure existing and empty directory for the Zip File if (dir.Exists) { dir.Delete(true); } dir.Create(); // Download zip package WebClient.DownloadFile(package.Packagelink, zipPath); // Remember path to package directory dicPackagePaths.Add(package, dirPath); } catch (Exception) { return(false); } return(true); }