如何更改StorageFile上的DateCreated?

Bil*_*ser 5 c# windows-phone-8 windows-store-apps

根据http://msdn.microsoft.com/en-us/library/windows/apps/windows.storage.storagefile.datecreated.aspx,StorageFile.DateCreated是只读的.

在桌面上,我可以这样做:

IStorageFile file = ...
DateTime date = ...
BasicProperties props = await file.GetBasicPropertiesAsync();
var changes = new List<KeyValuePair<string,object>>();
changes.Add(new KeyValuePair<string, object>("System.DateCreated", date));
await props.SavePropertiesAsync(changes);
Run Code Online (Sandbox Code Playgroud)

但是在WP8上,没有实现BasicProperties.SavePropertiesAsync.

还有其他方法可以做到这一点吗?

Ada*_*dam 0

一种方法是获取创建日期并使用ApplicationData.LocalSettings来存储文件路径和创建日期。风险在于您必须确保每次创建文件时都会更新该值。

否则,您可以使用moveAndReplaceAsync移动文件并重置创建日期。

您还可以将这些值存储在您自己的辅助文件或数据库中,但这在每个文件读取时都需要额外的 IO。(您必须打开两个文件才能获取文件内容和“创建日期”)。