// should return the local path to the .zip file public string DownloadComponent(VFComponent component, string downloadDirectory = null, WebClient.DownloadPercent downloadCallback = null) { if (string.IsNullOrWhiteSpace(downloadDirectory)) { downloadDirectory = this.m_defaultDownloadDirectory; } Directory.CreateDirectory(downloadDirectory); string zipFileName = Path.Combine(downloadDirectory, component.name + ".zip"); if (downloadCallback == null) { downloadCallback = new WebClient.DownloadPercent((percent) => { }); } try { if (this.m_vfWebClient.DownloadFile(zipFileName, component.zip_url, downloadCallback)) { // downloaded successfully return(zipFileName); } else { // failed to download return(null); } } catch (System.Net.WebException webEx) { Trace.TraceError("WebException thrown when attempting component download."); Trace.TraceError("{0}", webEx.Message); Trace.TraceError("{0}", webEx.StackTrace); throw new VehicleForge.VFDownloadFailedException(); } }
public override bool DownloadFile(string fileName, string url, WebClient.DownloadPercent callback) { this.Login(); return(base.DownloadFile(fileName, url, callback)); }