保存联系人缩略图

时间:2013-03-08 23:52:32

标签: c# .net windows-8

我想将个人资料图片保存在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
}

1 个答案:

答案 0 :(得分:-1)

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

using (IRandomAccessStreamWithContentType stream = await contact.GetThumbnailAsync())
{
     using(FileStream fs = new FileStream("path", FileMode.CreateNew))
     {
          stream.CopyTo(fs);
     }
}