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