private void BatchDownload() { cancelEvent = new System.Threading.ManualResetEvent(false); string[] urls = new string[filenames.Length]; for (int i = 0; i < filenames.Length; i++) { urls[i] = ConfigurationValues.UpdateServerPath + filenames[i]; } using (HttpBatchDownloader dl = new HttpBatchDownloader()) { dl.UrlsInfo = new BatchUrlInfo[urls.Length]; for (int i = 0; i < urls.Length; i++) { dl.UrlsInfo[i] = new BatchUrlInfo(); dl.UrlsInfo[i].url = urls[i]; dl.UrlsInfo[i].length = filelengths[i]; } dl.CurrentProgressChanged += new DownloadProgressHandler(CurrentProgressProcess); dl.TotalProgressChanged += new DownloadProgressHandler(TotalProgressProcess); dl.FileCompleted += new DownloadProgressHandler(FileCompletedProcess); dl.Download(dstpath, cancelEvent); } }
private bool BatchDownload(string[] urls, string dstdir) { try { using (HttpBatchDownloader dl = new HttpBatchDownloader()) { dl.Download(urls, dstdir, null); } } catch { return(false); } return(true); }