我的目标是创建一个获取链接并将其下载到本地驱动器的类。该程序应该支持从http \ https \ ftp链接下载,而且在我的工作中,我有一个专用的代理(没有身份验证)。 主系统是通过asp.net下载的,每个学生都可以请求下载文件。 所有文件都是从50MB到无限大小的非常大的文件,因此它应该是一个快速下载程序。使用代理的多线程文件下载器c#
这是我currentcode:
public void DownloadLink(string link)
{
string filename ;
try
{
WebClient wc = new WebClient();
Uri downloadLink= new Uri(link);
wc.DownloadFileCompleted += new AsyncCompletedEventHandler(DownloadFileCompleted);
filename = link.Substring(link.LastIndexOf("/") + 1);
Console.WriteLine("Downloading File" + filename);
wc.DownloadFileAsync(downloadLink, filename);
}
catch (Exception i)
{
System.Console.WriteLine ("Failed" + i.ToString());
}
}
private void DownloadFileCompleted(object sender, AsyncCompletedEventArgs e)
{
Console.WriteLine("Download Completed");
}
这里是我的问题: 1.How可以实现同时下载? 2.如何设置我的代理Webclient? 3 WebClient.DownloadAsync支持https & ftp还是应该处理它? 4.有没有办法实现下载更快?我看到几个实现,包括HttpWebRequest,HttpWebResponse & Streams。它有更好的性能吗?
嗨,我没有与带宽问题,你能解释我更多的TPL或给我例如参考? – RonenIL 2011-04-05 18:07:49