Nelson T Joseph
Nelson T Joseph

Reputation: 2763

Download Files in wp7

I am developing a windows phone application which allows user to download files from server. The user can select multiple files simultaneously for download. It works perfectly when the user stay on current page until download completed. If the user navigate to other pages when the file download is in progress the download stops. The download should continue even if the user navigate to other pages.

Also when the application exits the download stops. When the user starts the application again the pending files should automatically start download.

How can I do these?

Upvotes: 1

Views: 940

Answers (2)

Richard Szalay
Richard Szalay

Reputation: 84724

If the files are large you should be using BackgroundTransferRequest, which will continue even if the application is not running and you can still track their progress.

For more information, see Background File Transfers Overview for Windows Phone

Upvotes: 6

MyKuLLSKI
MyKuLLSKI

Reputation: 5325

The first thing you need to understand is page navigation. If you are navigating from a page to another page (and not changing visibilitiea of controls) then as soon as you navigate your old page page is unloaded and null. If you have a global in your page that you navigated from then that's also null. So you have to put your downloading webclient or whatever at an application global level. Do all your downloading in App.xaml.cs or better yet create your own shared class among all pages.

Now when the application exists the App.xaml.cs Unloaded gets called. So before you unload the app you need to store the already downloaded portion in IsolatedStorage and when the app.xaml.cs gets relaunched in the loaded event handler you need to check to see if the user was downloading something in the isolated storage then complete the download.

Upvotes: 2

Related Questions