locked
Is there a way to update the Date Accessed or Date Modified value of a file?

    Question

  • I want to be able to essentially touch a file programatically to update either the Date Accessed or Date Modified fields. I am currently grabbing the file using GetFileAsync() which does not seem to update either of those fields. I need to use those fields for some bookkeeping but I don't need to open the file any further.

    I am looking for essentially the Metro app equivalent of System.File.IO.SetLastWriteTime/SetLastAccessTime

    Thanks!


    • Edited by ejcarp Monday, October 6, 2014 7:01 PM
    Monday, October 6, 2014 5:00 PM

Answers

  • It looks like the answer is no, this is not possible.

    http://social.msdn.microsoft.com/Forums/en-US/1c9dea41-a26f-40cc-b972-481f15137a00/changing-the-last-modified-datetime-or-a-file?forum=winappswithcsharp

    • Marked as answer by ejcarp Monday, October 6, 2014 10:06 PM
    Monday, October 6, 2014 10:06 PM

All replies

  • I tried using SavePropertiesAsync() but DateModified and DateAccessed are both read-only. What functions do update DateModified and DateAccessed?
    Monday, October 6, 2014 6:39 PM
  • I don't think there is a way to do this in Windows Store C#. you may be able to access the fields you need via C++. I recommend you see http://msdn.microsoft.com/en-us/library/windows/apps/aa363874.aspx

    Matt Small - Microsoft Escalation Engineer - Forum Moderator
    If my reply answers your question, please mark this post as answered.

    NOTE: If I ask for code, please provide something that I can drop directly into a project and run (including XAML), or an actual application project. I'm trying to help a lot of people, so I don't have time to figure out weird snippets with undefined objects and unknown namespaces.


    Monday, October 6, 2014 7:02 PM
    Moderator
  • Thanks, but that link does not work for me.
    Monday, October 6, 2014 7:12 PM
  • Try it now.

    Matt Small - Microsoft Escalation Engineer - Forum Moderator
    If my reply answers your question, please mark this post as answered.

    NOTE: If I ask for code, please provide something that I can drop directly into a project and run (including XAML), or an actual application project. I'm trying to help a lot of people, so I don't have time to figure out weird snippets with undefined objects and unknown namespaces.

    Monday, October 6, 2014 7:32 PM
    Moderator
  • It looks like the answer is no, this is not possible.

    http://social.msdn.microsoft.com/Forums/en-US/1c9dea41-a26f-40cc-b972-481f15137a00/changing-the-last-modified-datetime-or-a-file?forum=winappswithcsharp

    • Marked as answer by ejcarp Monday, October 6, 2014 10:06 PM
    Monday, October 6, 2014 10:06 PM