protected virtual bool TryDownloadAsset(Asset asset, out string errorMessage) { errorMessage = null; string downloadPath = ProductUpgraderInfo.GetAssetDownloadsPath(); string localPath = Path.Combine(downloadPath, asset.Name); WebClient webClient = new WebClient(); try { webClient.DownloadFile(asset.DownloadURL, localPath); asset.LocalPath = localPath; } catch (WebException webException) { errorMessage = "Download error: " + webException.Message; this.TraceException(webException, nameof(this.TryDownloadAsset), $"Error downloading asset {asset.Name}."); return(false); } return(true); }
public void DeleteAllInstallerDownloads() { try { this.fileSystem.DeleteDirectory(GetAssetDownloadsPath()); } catch (Exception ex) { if (this.tracer != null) { this.tracer.RelatedError($"{nameof(this.DeleteAllInstallerDownloads)}: Could not remove directory: {ProductUpgraderInfo.GetAssetDownloadsPath()}.{ex.ToString()}"); } } }