将网络上的图像保存到Windows Phone 8.1 RT C#中的“已保存的图片”文件夹中
问题描述:
如何将图像保存到Windows Phone 8.1 RT中的已保存的图片文件夹中?我使用HttpClient从网上下载了图片。
How can I save an image to the Saved Pictures folder in Windows Phone 8.1 RT? I downloaded the image from the web using HttpClient.
答
您只需要这个
var url = "Some URL";
var fileName = Path.GetFileName(url.LocalPath);
var thumbnail = RandomAccessStreamReference.CreateFromUri(url);
var remoteFile = await StorageFile.CreateStreamedFileFromUriAsync(fileName, url, thumbnail);
await remoteFile.CopyAsync(KnownFolders.SavedPictures, fileName, NameCollisionOption.GenerateUniqueName);
您需要在清单中设置图片库功能。
You need to set the Pictures Library capability in your manifest.