Exception when trying to set last access of a file

Hi together,

i try to set the last access date of a file with System.IO.File.SetLastAccessTime(string path, DateTime date).
I need this to delete a downloaded file in temporary directory after a specific time, when no access happened.

On iOS it seems to work fine, but on Android i get a following IOException:

System.IO.IOException: Invalid parameter
at System.IO.File.SetLastAccessTime (System.String path, System.DateTime lastAccessTime) [0x00029] in /Users/builder/data/lanes/3511/77cb8568/source/mono/mcs/class/corlib/System.IO/File.cs:480

The exception mentions an invalid parameter, but the path is correct because the GetLastAccessTime(string path) with the same string returns the right date value. Also the DateTime parameter has the correct formatting (I use DateTime.Now).

  • I also tried to block the thread during file access.
  • The permissions for writing are also set.
  • The SetLastWriteTime method also throws the same kind of exception

Also strange is that it works on our Sony Xperia Z3 test device with Android 6, but on no other device.

Tested on:
Samsung Galaxy S5 Android 5.0.2
Galaxy Tab with Android 4.4
Google Pixel C with Android 7

Anyone clues or solutions for this problem?

Answers

  • philCrouchphilCrouch USMember

    Did you ever have any luck with this?
    I am having the same issue.

    Cheers

Sign In or Register to comment.