Reputation: 2183
How would I download a large file in Windows Phone 7 with a progress bar?
Upvotes: 3
Views: 1656
Reputation: 4962
While Claus's answer would work, a potentially easier solution would be to use a web client. It would look something like this:
...
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";
}
This code would show a progress bar with the progress and a text block with the progress in MB.
Upvotes: 8
Reputation: 26351
See Microsofts How to: Implement Background File Transfers for Windows Phone
Upvotes: 2