0

我想将个人资料图片保存在本地存储的文件中。

使用此代码检索 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
}
4

1 回答 1

-1

假设IRandomAccessStreamWithContentType像任何其他流一样工作,这应该可以解决问题:

using (IRandomAccessStreamWithContentType stream = await contact.GetThumbnailAsync())
{
     using(FileStream fs = new FileStream("path", FileMode.CreateNew))
     {
          stream.CopyTo(fs);
     }
}
于 2013-03-09T00:48:33.767 回答