我正在尝试Windows 8.1的后台下载程序。这是我从Background Downloader示例中获得的HandleDownloadAsync()
。
它开始获得FileNotFound Exception
await download.StartAsync().AsTask(cts.Token, progressCallback);
几天前工作了,我没有改变代码。所有变量也分配了正确的值。
有什么问题?
async void HandleDownloadAsync(DownloadOperation download, bool start)
{
activeDownloads.Add(download);
try
{
Progress<DownloadOperation> progressCallback = new Progress<DownloadOperation>(ProgressCallback);
if (start)
{
await download.StartAsync().AsTask(cts.Token, progressCallback);
}
else
{
await download.AttachAsync().AsTask(cts.Token, progressCallback);
}
}
catch (Exception ex)
{
}
finally
{
activeDownloads.Remove(download);
}
}