0x00.添加引用
using System; using System.Threading.Tasks; using Windows.Networking.BackgroundTransfer; using Windows.Storage;
0x01.下载
Uri uri = new Uri(imageUri);//需要下载图片的Uri,exp:http*****.jpg BackgroundDownloader backgroundDownload = new BackgroundDownloader(); StorageFolder folder = await KnownFolders.PicturesLibrary.CreateFolderAsync("Acafe", CreationCollisionOption.OpenIfExists);//此处为下载路径,可是要Openfolder改为自定义路径 StorageFile newFile = await folder.CreateFileAsync(imageName, CreationCollisionOption.OpenIfExists);//创建文件,需要定义文件名 DownloadOperation download = backgroundDownload.CreateDownload(uri, newFile);//创建下载器 await download.StartAsync();//启动