예제 #1
0
        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);
            }
        }
예제 #2
0
 private bool BatchDownload(string[] urls, string dstdir)
 {
     try
     {
         using (HttpBatchDownloader dl = new HttpBatchDownloader())
         {
             dl.Download(urls, dstdir, null);
         }
     }
     catch
     {
         return(false);
     }
     return(true);
 }