我想一些幫助來獲得聯繫人的縮略圖並將其保存到本地存儲,我順利地拿到了接觸縮略圖,但我不能讓從流實際的形象,這是我的代碼:UWP - 如何將聯繫人縮略圖保存到本地存儲?
var contactStore = await ContactManager.RequestStoreAsync();
var contacts = await contactStore.FindContactsAsync();
var myContact = contacts[0]; //I am sure that this Contact has a Thumbnail
var stream = await myContact.Thumbnail.OpenReadAsync();
byte[] buffer = new byte[stream.Size];
var readBuffer = await stream.ReadAsync(buffer.AsBuffer(), (uint)buffer.Length, InputStreamOptions.None);
var file = await ApplicationData.Current.LocalFolder.CreateFileAsync("image.jpg", CreationCollisionOption.ReplaceExisting);
var fileStream = await file.OpenStreamForWriteAsync();
await fileStream.WriteAsync(readBuffer.ToArray(), 0, (int)readBuffer.Length);
這段代碼在本地存儲中創建一個空的圖像,有幫助嗎?
感謝您的時間
大它只是完美的,謝謝 – MohamedMokhtar