我正在使用Windows Phone下载带有WebClient的文件。 DownloadProgressChanged事件不起作用。它只触发一次,为DownloadProgressChangedEventArgs.BytesRecieved返回值“4923206”。我的代码是:
private void listBox1_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
WebClient wb = new WebClient();
wb.DownloadProgressChanged += wbchange;
wb.OpenReadAsync(new Uri("http://sohowww.nascom.nasa.gov/data/LATEST/current_eit_304small.gif"));
}
private void wbchange(object sender, DownloadProgressChangedEventArgs e)
{
MessageBox.Show(e.BytesReceived.ToString()); (obviously in the end I will not be showing a message at every change)
}
这有什么问题?
答案 0 :(得分:0)
它工作得很好,它恰好已经下载了第一个DownloadProgressChanged
调用的所有字节。
如果你read the documentation,你会发现这是预期的行为。