Bug 3029 - File.SetLastWriteTimeUtc() fails with System.IO.IOException on Android 3.0
Summary: File.SetLastWriteTimeUtc() fails with System.IO.IOException on Android 3.0
Status: RESOLVED UPSTREAM
Alias: None
Product: Android
Classification: Xamarin
Component: BCL Class Libraries ()
Version: 4.0
Hardware: PC Windows
: --- normal
Target Milestone: ---
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2012-01-24 11:51 UTC by info
Modified: 2012-02-08 16:58 UTC (History)
2 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED UPSTREAM

Description info 2012-01-24 11:51:28 UTC
The following example code works as expected on Android 2.3 (tested with LG Optimus 2X and LG Optimus One) but fails with an Exception on Android 3.2 (tested with Motorola Xoom)

File.WriteAllText("/sdcard/Hello.txt", "HELLO");
File.SetLastWriteTimeUtc("/sdcard/Hello.txt", DateTime.UtcNow);

The Exception thrown on the Motorola Xoom with Android 3.2 is:

System.IO.IOException: Invalid parameter
  at System.IO.File.SetLastWriteTime (System.String path, DateTime lastWriteTime) [0x00029] in /home/jon/Development/xamarin/mono/mcs/class/corlib/System.IO/File.cs:467
  at System.IO.File.SetLastWriteTimeUtc (System.String path, DateTime lastWriteTimeUtc) [0x00000] in /home/jon/Development/xamarin/mono/mcs/class/corlib/System.IO/File.cs:473

Using Mono for Android 4.0.3. Maybe this is not due to the Android version, but due to the Motorola Xoom. However, I do not have another Android 3.x or 4.x device to check this out.
Comment 1 info 2012-02-07 07:32:14 UTC
It seems that this is general problem on some Android devices and is not a bug of Mono for Android. See: http://code.google.com/p/android/issues/detail?id=15480
Comment 2 Jonathan Pobst 2012-02-08 16:58:29 UTC
Thanks for the follow-up.  We rely on the Android platform to provide this functionality, so it will require a fix from them.

Unfortunately, if devices in the wild are broken, there's a good chance no one will be able to rely on devices working correctly for a long time.  :(