如何更改StorageFile上的DateCreated?

时间:2013-07-25 21:29:57

标签: c# windows-phone-8 windows-store-apps

Per 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);

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

还有其他方法吗?

1 个答案:

答案 0 :(得分:0)

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

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

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

相关问题