I'm trying to download a file with this code:
private async void Button_Click(object sender, RoutedEventArgs e)
{
try
{
Uri source;
Uri.TryCreate(txbUri.Text.Trim(),UriKind.Absolute, out source);
StorageFile destfile = await x.CreateFileAsync(Path.GetFileName(source.LocalPath), CreationCollisionOption.GenerateUniqueName);
BackgroundDownloader downloader = new BackgroundDownloader();
DownloadOperation download = await Task.Run(() => { return downloader.CreateDownload(source, destfile); });
await HandleDownloadAsync(download, true);
}
catch(Exception ex)
{
MessageBox.Show(ex.ToString());
}
}
but there is a exception on the line:
downloader.CreateDownload(source, destfile);
the exception is:
class not registered
I Compiled Microsoft sample with the exact codes and it worked fine. But I don't know why my App Doesn't.