Windows Phone 7 - 如何下载带有进度的文件?

时间:2012-09-08 20:49:47

标签: windows-phone-7

如何使用进度条在Windows Phone 7中下载大文件?

2 个答案:

答案 0 :(得分: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进度的文本块。

答案 1 :(得分:2)