参考链接:https://github.com/bezzad/Downloader
public static async Task<bool> HttpDownloadFile(string downloadUrl, string localPath, log4net.ILog log)
         {
             bool bFlagDownloadFile = false;
             //log.Debug("HttpDownloadFile--准备以HTTP的方式下载文件,url:[" + downloadUrl + "]本地文件:【" + localPath + "】");
             
             var downloadOpt = new DownloadConfiguration()
             {
                 // usually, hosts support max to 8000 bytes, default value is 8000
                 BufferBlockSize = 10240,
                 // file parts to download, the default value is 1
                 ChunkCount = 8,
                 // download speed limited to 2MB/s, default values is zero or unlimited
                 //MaximumBytesPerSecond = 1024 * 1024 * 12,
                 // the maximum number of times to fail
                 MaxTryAgainOnFailover = 5,
                 // release memory buffer after each 50 MB
                 MaximumMemoryBufferBytes = 1024 * 1024 * 50,
                 // download parts of the file as parallel or not. The default value is false
                 ParallelDownload = true,
                 // number of parallel downloads. The default value is the same as the chunk count
                 ParallelCount = 4,
                 // timeout (millisecond) per stream block reader, default values is 1000
                 Timeout = 1000,
                 // set true if you want to download just a specific range of bytes of a large file
                 RangeDownload = false,
                 // floor offset of download range of a large file
                 RangeLow = 0,
                 // ceiling offset of download range of a large file
                 RangeHigh = 0,
                 // clear package chunks data when download completed with failure, default value is false
                 ClearPackageOnCompletionWithFailure = true,
                 // minimum size of chunking to download a file in multiple parts, the default value is 512
                 MinimumSizeOfChunking = 1024,
                 // Before starting the download, reserve the storage space of the file as file size, the default value is false
                 ReserveStorageSpaceBeforeStartingDownload = true,
                 // config and customize request headers
                 RequestConfiguration = 
                 {
                     Accept = "*/*",
                     //CookieContainer = cookies,
                     Headers = new WebHeaderCollection(), // { your custom headers }
                     KeepAlive = true, // default value is false
                     ProtocolVersion = HttpVersion.Version11, // default value is HTTP 1.1
                     UseDefaultCredentials = false,
                     // your custom user agent or your_app_name/app_version.
                     UserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64)",
                     Proxy = new WebProxy()
                     {
                         Address = new Uri("http://YourProxyServer/proxy.pac"),
                         UseDefaultCredentials = false,
                         Credentials = System.Net.CredentialCache.DefaultNetworkCredentials,
                         BypassProxyOnLocal = true
                     }
                 }
             };
            try
             {
                 var downloader = new DownloadService(downloadOpt);
                 await downloader.DownloadFileTaskAsync(downloadUrl, localPath);
                 bFlagDownloadFile = true;
                 log.Debug("HttpDownloadFile--以HTTP的方式下载文件,本地文件:【" + localPath + "】成功!");                
             }
             catch (Exception ex)
             {
                 log.Error("HttpDownloadFile--以HTTP的方式下载文件,本地文件:【" + localPath + "】时发生错误!异常消息:" + ex.Message, ex);
                 bFlagDownloadFile = false;
             }
            return bFlagDownloadFile;
         }