ImageProperties.SaveImagePropertiesAsync() ไม่บันทึกการเปลี่ยนแปลง

ฉันกำลังพยายามบันทึกคุณสมบัติบางอย่างลงในไฟล์รูปภาพในแอปพลิเคชัน Windows 10 UWP บนโทรศัพท์มือถือ

var fileProperties = await file.Properties.GetImagePropertiesAsync();

fileProperties.Rating = 25;
fileProperties.Title = "Title";
fileProperties.DateTaken = DateTime.Now;

await file.Properties.SavePropertiesAsync();

ด้วยเหตุผลบางประการ คุณสมบัติจะไม่ถูกบันทึก

ไฟล์จะถูกสร้างขึ้นล่วงหน้าดังนี้:

var file = await _sourceFolder.CreateFileAsync(pathToFile, CreationCollisionOption.ReplaceExisting);
await bitmap.SaveToStorageFile(file);

โดยที่บิตแมปเป็นประเภท WriteableBitmap รูปภาพถูกบันทึกลงในไฟล์ แต่คุณสมบัติไม่ได้เป็นเช่นนั้น

ไม่มีใครรู้ว่าสิ่งที่ฉันทำไม่ถูกต้อง? ไม่มีข้อยกเว้น ไม่มีข้อความว่าทำไมจึงไม่สำเร็จ


person robcsi    schedule 25.04.2017    source แหล่งที่มา


คำตอบ (1)


ปัญหาที่นี่คือ StorageFile.Properties.SavePropertiesAsync ซึ่งได้รับ StorageItemContentProperties และใช้ข้อมูลต้นฉบับในการบันทึกลงไฟล์

คุณควรจะสามารถใช้วิธี ImageProperties.SavePropertiesAsync ได้ ใช้ข้อมูล ImageProperties ใหม่เพื่อบันทึกลงในไฟล์

ตัวอย่างเช่น:

var fileProperties = await file.Properties.GetImagePropertiesAsync();
fileProperties.Rating = 25;
fileProperties.Title = "title";
fileProperties.DateTaken = DateTime.Now;
await fileProperties.SavePropertiesAsync();
person Jayden    schedule 26.04.2017
comment
โอ้ แย่แล้ว... ขอบคุณสำหรับความช่วยเหลือ กำลังทำเครื่องหมายคำตอบของคุณว่าเป็นคำตอบ มันได้ผล. - person robcsi; 26.04.2017