gpt4 book ai didi

c# - 如何更改 StorageFile 上的 DateCreated?

转载 作者:太空狗 更新时间:2023-10-29 23:51:34 27 4
gpt4 key购买 nike

根据 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 没有实现。

还有其他方法吗?

最佳答案

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

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

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

关于c# - 如何更改 StorageFile 上的 DateCreated?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17869078/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com