Windows应用商店应用BackgroundDownloader工作示例

时间:2015-01-10 22:47:42

标签: c# windows-store-apps

我已经在MSDN上查看了,但是找不到这个类的工作示例。

在我的Windows商店应用中,我想在后台下载多个文件。我看到有BackgroundDownloader类和CreateDownloadAsync函数,但我无法弄清楚requestBodyStream参数的用途。这是我的示例代码,抛出requestBodyStream参数为null Exception。我尝试使用InputStreamOverStream和FileInput流进行初始化,但两者都给出了"类型' Windows.Storage.Streams.InputStreamOverStream'没有定义构造函数"错误。

我错过了什么吗?

string downloadUrl = videoInfo.DownloadUrl;
BackgroundDownloader backgroundDownloader = new BackgroundDownloader();
Uri uri = new Uri(downloadUrl);
Windows.Storage.IStorageFile resultFile = null;
Windows.Storage.Streams.IInputStream requestBodyStream = null;
IAsyncOperation<DownloadOperation> asyncOperation = backgroundDownloader.CreateDownloadAsync(uri, resultFile, requestBodyStream);
asyncOperation.Completed += delegate(IAsyncOperation<DownloadOperation> info, AsyncStatus status)
{
DownloadOperation downloadOperation = info.GetResults();

};

0 个答案:

没有答案