0
我有一个格式为http://ww.url.com/page?id=200的网址。这将下载一个10 MB的文件。不过,我总是将e.ProgressPercentage设为0。但它实际上读取的结果是上传完成函数。下载AsyncData的WebClient失败
请告诉我我在做什么错在这里。
我使用以下代码
private void button1_Click(object
sender, EventArgs e)
{
WebClient webClient = new WebClientEx();
webClient.DownloadProgressChanged +=
new DownloadProgressChangedEventHandler(wc_DownloadProgressChanged);
webClient.DownloadDataCompleted += new
DownloadDataCompletedEventHandler(wc_DownloadComplete);
webClient.DownloadDataAsync(new Uri("http://ww.url.com/page?id=200"));
}
public void wc_DownloadProgressChanged(Object sender,
DownloadProgressChangedEventArgs e)
{
Progress1.Value = e.ProgressPercentage; // this is 0
}
public void wc_DownloadComplete(Object sender,DownloadDataCompletedEventArgs e)
{
int a = 0;
this.Close();
}
} }
也许它是由您的格式造成的( - :) – 2010-12-02 21:08:30