앱 시작 (처음 실행) 할 때 다운로드해야하는 파일이 있습니다. 나는 윈도우 8 의 백그라운드 다운로더를 사용하고 이것은 내가 그것을 사용하는 방법입니다 백그라운드 다운로더 창 8 여러 파일
BackgroundDownloader downloader = new BackgroundDownloader();
List<DownloadOperation> operations = new List<DownloadOperation>();
foreach (FileInfo info in infoFiles)
{
Windows.Storage.ApplicationData.Current.LocalFolder;
foreach (string folder in info.Folders)
{
currentFolder = await currentFolder.CreateFolderAsync(folder, CreationCollisionOption.OpenIfExists);
}
//folder hierarchy created, save the file
StorageFile file = await currentFolder.CreateFileAsync(info.FileName, CreationCollisionOption.ReplaceExisting);
DownloadOperation op = downloader.CreateDownload(new Uri(info.Url), file);
activeDownloads.Add(op);
operations.Add(op);
}
foreach (DownloadOperation download in operations)
{
//start downloads
await HandleDownloadAsync(download, true);
}
나는 하나의 배경 다운로드가 발견 얻을 BackgroundDownloader.GetCurrentDownloadsAsync();
를 사용하려고
그러나 진행률 표시 줄을 설정할 수 있도록 모든 파일이 완료되면 알 필요가 있습니다.
여러 파일을 다운로드하고 모든 파일이 BackgroundDownloader.GetCurrentDownloadsAsync();
에서 발견되고 모든 다운로드가 완료되면 알 수있는 방법이 필요합니다. 특별히 모든 응용 프로그램 시작시 파일을 다시 다운로드해야하는 경우
private async Task HandleDownloadAsync(DownloadOperation download, bool start)
{
try
{
Debug.WriteLine("Running: " + download.Guid, NotifyType.StatusMessage);
// Store the download so we can pause/resume.
activeDownloads.Add(download);
Progress<DownloadOperation> progressCallback = new Progress<DownloadOperation>(DownloadProgress);
if (start)
{
// Start the download and attach a progress handler.
await download.StartAsync().AsTask(cts.Token, progressCallback);
}
else
{
// The download was already running when the application started, re-attach the progress handler.
await download.AttachAsync().AsTask(cts.Token, progressCallback);
}
ResponseInformation response = download.GetResponseInformation();
Debug.WriteLine(String.Format("Completed: {0}, Status Code: {1}", download.Guid, response.StatusCode),
NotifyType.StatusMessage);
}
catch (TaskCanceledException)
{
Debug.WriteLine("Canceled: " + download.Guid, NotifyType.StatusMessage);
}
catch (Exception ex)
{
if (!IsExceptionHandled("Execution error", ex, download))
{
throw;
}
}
finally
{
activeDownloads.Remove(download);
}
}
당신이 봤어 [빠른 시작 : 파일 다운로드] (http://msdn.microsoft.com/en-us/library/windows/apps/jj152726.aspx)? – Harrison