Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/339.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何更改在StorageFile上创建的日期?_C#_Windows Phone 8_Windows Store Apps - Fatal编程技术网

C# 如何更改在StorageFile上创建的日期?

C# 如何更改在StorageFile上创建的日期?,c#,windows-phone-8,windows-store-apps,C#,Windows Phone 8,Windows Store Apps,根据,StorageFile.DateCreated是只读的 在桌面上,我可以执行以下操作: IStorageFile file = ... DateTime date = ... BasicProperties props = await file.GetBasicPropertiesAsync(); var changes = new List<KeyValuePair<string,object>>(); changes.Add(new KeyValuePair&l

根据,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);
IStorageFile文件=。。。
日期时间日期=。。。
BasicProperties props=await file.getBasicProperties异步();
var changes=新列表();
添加(新的KeyValuePair(“System.DateCreated”,date));
等待道具。保存属性同步(更改);
但是在WP8上,没有实现BasicProperties.SavePropertiesAsync


还有其他方法吗?

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

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

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