public async Task <string> DownloadReleaseFile(string url) { IFileDownloader downloader; string releaseFile; if (url.EndsWith("/")) { url = url.Substring(0, url.Length - 1); } if (Utility.IsHttpUrl(url)) { downloader = new FileDownloader(); } else if (Utility.IsFtpUrl(url)) { downloader = new FtpFileDownloader(); } else { return(null); } int retries = 3; while (retries-- > 0) { try { var uri = Utility.AppendPathToUri(new Uri(url), "RELEASES"); var data = await downloader.DownloadUrl(uri.ToString()); return(Encoding.UTF8.GetString(data)); } catch (WebException ex) { this.Log().InfoException("Download resulted in WebException (returning blank release list)", ex); } } return(null); }
public void Test_FtpDownload() { using (var testPipeline = new Pipeline()) { var ftpDownloader = new FtpFileDownloader() { Host = "ftp://speedtest.tele2.net", RemoteDirectory = @"\\1KB.zip", LocalDirectory = this.resultPath, User = "", Password = "" }; testPipeline.Commands.Add(ftpDownloader); testPipeline.ExecutePipeline(); // check if (!File.Exists(this.resultPath + @"1KB.zip")) { throw new Exception("Downloaded file was not found"); } } }