0

I tried to set the Creation time, Last Write Time and Last Access Time of a file in Xamarin forms (Android). To do this I used this simple code:

File.SetCreationTime(path, DateTime);
File.SetLastWriteTime(path, DateTime);
File.SetLastAccessTime(path, DateTime);

But it sets the Creation Time the same as the Last Write Time and i got no exception. What should i do to fix this problem? On Windows it works fine...

Thanks for your help!

asked Feb 22, 2021 at 22:27
4
  • "If the file system implementation does not support a time stamp to indicate the time when the file was created then this method returns an implementation specific default value, typically the last-modified-time" - developer.android.com/reference/java/nio/file/attribute/… Commented Feb 22, 2021 at 22:32
  • Windows and Android use different file systems. And I don't believe there is any standard file system that all Android versions/devices use. So relying on these file attributes is probably not a good idea. Commented Feb 23, 2021 at 1:52
  • @Jason do you know an alternative Filesystem for android? Only the File.SetCreationTime() does not work the others working fine - thats, why im wondering.. Commented Feb 23, 2021 at 12:30
  • You can't control the file system being used by the device. I think you just need to accept that this is not a reliable piece of data and find a different approach. Commented Feb 23, 2021 at 12:37

0

Know someone who can answer? Share a link to this question via email, Twitter, or Facebook.

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.