我想将个人资料图片保存在localstorage的文件中。
使用此代码检索IRandomAccessStreamWithContentType但我不明白如何将其保存在磁盘上。
var contactPicker = new Windows.ApplicationModel.Contacts.ContactPicker();
contactPicker.CommitButtonText = "Select";
var contact = await contactPicker.PickSingleContactAsync();
using (IRandomAccessStreamWithContentType stream = await contact.GetThumbnailAsync())
{
//Save stream on LocalFolder
}
答案 0 :(得分:-1)
假设IRandomAccessStreamWithContentType
与其他任何流一样,这应该可以解决问题:
using (IRandomAccessStreamWithContentType stream = await contact.GetThumbnailAsync())
{
using(FileStream fs = new FileStream("path", FileMode.CreateNew))
{
stream.CopyTo(fs);
}
}