Windows runtime 一起使用backgrounddownloader和savefilepicker?

Windows runtime 一起使用backgrounddownloader和savefilepicker?,windows-runtime,Windows Runtime,大家好,我有一个小winrt应用程序,可以从internet下载视频,我试图同时实现backgrounddownloader和filesavepicker,但我搜索了google和microsoft文档,但没有发现任何错误。我通过HttpClient类实现了下载,但我想要的是要获得下载进度,HttpClient不提供下载进度。请提前下载Thx // set download URI var uri = new Uri("http://s3.amazonaws.com/thetabletshow/

大家好,我有一个小winrt应用程序,可以从internet下载视频,我试图同时实现backgrounddownloader和filesavepicker,但我搜索了google和microsoft文档,但没有发现任何错误。我通过HttpClient类实现了下载,但我想要的是要获得下载进度,HttpClient不提供下载进度。请提前下载Thx

// set download URI
var uri = new Uri("http://s3.amazonaws.com/thetabletshow/thetabletshow_0072_lhotka.mp3");
// get destination file
var picker = new FileSavePicker();
// set allowed extensions
picker.FileTypeChoices.Add("MP3", new List<string> { ".mp3" });
var file = await picker.PickSaveFileAsync();

// create a background download
var downloader = new BackgroundDownloader();
var download = downloader.CreateDownload(uri, file);

// create progress object
var progress = new Progress<DownloadOperation>();
// attach an event handler to get notified on progress
progress.ProgressChanged += (o, operation) => 
    { 
        // use the progress info in Progress.BytesReceived and Progress.TotalBytesToReceive
        ProgressText.Text = operation.Progress.BytesReceived.ToString(); 
    };
// start the actual download
await download.StartAsync().AsTask(progress);
//设置下载URI
var uri=新的uri(“http://s3.amazonaws.com/thetabletshow/thetabletshow_0072_lhotka.mp3");
//获取目标文件
var picker=new FileSavePicker();
//设置允许的扩展名
添加(“MP3”,新列表{.MP3});
var file=await picker.PickSaveFileAsync();
//创建后台下载
var downloader=new BackgroundDownloader();
var download=downloader.CreateDownload(uri,文件);
//创建进度对象
var progress=新进度();
//附加事件处理程序以获得进度通知
progress.ProgressChanged+=(o,操作)=>
{ 
//使用progress.BytesReceived和progress.TotalByTestOreReceive中的进度信息
ProgressText.Text=operation.Progress.BytesReceived.ToString();
};
//开始实际下载
等待下载.StartAsync().AsTask(进度);

从现在开始,您应该能够根据需要修改它。

您应该添加一些关于问题实际是什么(错误消息等)以及您正在使用什么语言(C++、C#或JavaScript)开发的信息。请告诉我们有关您尝试过的内容和遇到的错误的更多信息。