win8 中实现断点续传

1) Resume method does resume on cases where resume is possible. Meaning if the server accepts range-requests, the download would resume, otherwise restart.

2) When you are creating the storage file store your data, you have to use GenerateUnique name enum value to avoid overriding the existing file.

StorageFile destinationFile = await KnownFolders.PicturesLibrary.CreateFileAsync(
                    destination,CreationCollisionOption.GenerateUniqueName);BackgroundDownloader downloader =newBackgroundDownloader();DownloadOperation download = downloader.CreateDownload(source, destinationFile)

3) If the HttpClient is giving you a hard time with the download, you can always embellish it with a download progress. This would sustain the fluid UI and avoid non responsive application. Here is an example that is to be used with servers which allow chunked encoding: Download / Send Request Async with Progress

Posted in: Windows 8WinRT. Tagged: ,. 11 Comments

Hope it helps, and you might want to try to post it to a local group rather than the english one. You might get more responses.

原文地址:https://www.cnblogs.com/CharlesGrant/p/3639214.html