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!
-
"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/…Jason– Jason2021年02月22日 22:32:31 +00:00Commented 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.Jason– Jason2021年02月23日 01:52:49 +00:00Commented 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..Emil– Emil2021年02月23日 12:30:04 +00:00Commented 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.Jason– Jason2021年02月23日 12:37:25 +00:00Commented Feb 23, 2021 at 12:37
lang-cs