private void downloader_DoWork(object sender, DoWorkEventArgs e) { int count = 0; foreach (PackageDetails package in packages) { Stream outputStream = File.Create(Path.Combine(downloadLocation, package.Name + ".zip")); try { IFileTransfer fileTransfer = project.RetrieveFileTransfer(package.FileName); fileTransfer.Download(outputStream); } finally { outputStream.Flush(); outputStream.Close(); } downloader.ReportProgress(count++); } }
/// <summary> /// Retrieve a file transfer object. /// </summary> /// <param name="project">The project to retrieve the file for.</param> /// <param name="fileName">The name of the file.</param> public virtual IFileTransfer RetrieveFileTransfer(string fileName) { return(projectMonitor.RetrieveFileTransfer(fileName)); }