虽然克劳斯的答案可行,但一个可能更容易的解决方案是使用网络客户端.它看起来像这样:
...
WebClient wb = new WebClient();
wb.DownloadProgressChanged += wbchange;
...
private void wbchange(object sender, DownloadProgressChangedEventArgs e)
{
progressBar2.Value = e.BytesReceived;
progressBar2.Maximum = e.TotalBytesToReceive;
int val = (int)(e.BytesReceived / 1048576);
int max = (int)(e.TotalBytesToReceive / 1048576);
textBlock4.Text = val + "MB out of " + max.ToString() + "MB";
}
Run Code Online (Sandbox Code Playgroud)
此代码将显示带有进度的进度条和带有MB进度的文本块.
| 归档时间: |
|
| 查看次数: |
1644 次 |
| 最近记录: |