3

如何在 Windows Phone 7 中下载带有进度条的大文件?

4

2 回答 2

8

虽然克劳斯的回答会奏效,但可能更简单的解决方案是使用网络客户端。它看起来像这样:

    ...
    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";
    }

此代码将显示一个带有进度的进度条和一个带有 MB 进度的文本块。

于 2012-09-08T22:18:44.317 回答
2

请参阅 Microsoft如何:为 Windows Phone 实现后台文件传输

于 2012-09-08T21:05:46.587 回答