Bug 16438 - File.SetCreationTime and File.SetLastWriteTime do not work
Summary: File.SetCreationTime and File.SetLastWriteTime do not work
Alias: None
Product: Runtime
Classification: Mono
Component: io-layer ()
Version: 3.2.x
Hardware: Macintosh Mac OS
: --- enhancement
Target Milestone: ---
Assignee: Bugzilla
Depends on:
Reported: 2013-11-25 12:01 UTC by Reng Zeng
Modified: 2014-01-08 21:05 UTC (History)
4 users (show)

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 GitHub or Developer Community 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:

Description Reng Zeng 2013-11-25 12:01:22 UTC
Description of Problem:
On both Mac Mountain Lion and Mavericks, File.SetCreationTime and File.SetLastWriteTime do not work. I also tried using FileInfo class, no luck.

Steps to reproduce the problem:
                File.SetCreationTime("test011.txt", new DateTime(635204782730000000));
            catch (Exception ex)
                FileInfo fi = new FileInfo("test011.txt");
                fi.CreationTimeUtc = new DateTime(635204782740000000);
            catch (Exception ex)

Actual Results:
Calling those functions do not have any effects to the file. 
No exceptions.

Expected Results:
The creationtime and modifedtime should be properly set and can be checked in Finder.

How often does this happen? 

Additional Information:
Comment 1 Reng Zeng 2013-11-25 12:13:18 UTC
To be clear:
File.SetCreationTime does not have any effects to the file.
File.SetLastWriteTime change both "Date Modified" and "Date Created"
Comment 2 Zoltan Varga 2013-11-27 04:32:36 UTC
This is how unix works, you cannot set the file creation time.
Comment 3 Reng Zeng 2013-11-27 08:51:14 UTC
But Cocoa API allows me to set the file creation time as shown below. Why not for Mono on Mac?
        NSFileManager *m = [NSFileManager defaultManager];
        NSString *path = @"test011.txt";
        [m setAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[NSDate date],NSFileCreationDate,nil] ofItemAtPath:path error:nil];
Comment 4 Rodrigo Kumpera 2013-12-10 16:53:04 UTC
We follow posix semantics on OSX as much as possible.