[Mono-bugs] [Bug 71212][Nor] New - System.IO.File.SetLastWriteTime modifies the Creation time

bugzilla-daemon@bugzilla.ximian.com bugzilla-daemon@bugzilla.ximian.com
Wed, 12 Jan 2005 13:55:39 -0500 (EST)


Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.

Changed by cgaisford@novell.com.

http://bugzilla.ximian.com/show_bug.cgi?id=71212

--- shadow/71212	2005-01-12 13:55:39.000000000 -0500
+++ shadow/71212.tmp.15677	2005-01-12 13:55:39.000000000 -0500
@@ -0,0 +1,77 @@
+Bug#: 71212
+Product: Mono: Class Libraries
+Version: 1.1
+OS: 
+OS Details: OS X 10.3.7
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Normal
+Component: System
+AssignedTo: mono-bugs@ximian.com                            
+ReportedBy: cgaisford@novell.com               
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: System.IO.File.SetLastWriteTime modifies the Creation time
+
+When calling System.IO.File.SetLastWriteTime on a file, the Creation time
+is also modified.  On Linux, the Creation time and Write Time are one and
+the same, however on OSX, these are different values and should be able to
+be set individually as they are done on Windows.
+
+Here is a sample app that shows the problem:
+
+
+using System;
+
+public class tester
+{
+    public static void writeTime(string type, System.DateTime dt)
+    {
+        Console.WriteLine("{0} Date: {1}/{2}/{3} Time: {4}:{5}:{6}:{7}",
+type, dt.Month, dt.Day, dt.Year, dt.Hour, dt.Minute, dt.Second,
+dt.Millisecond);
+    }
+
+    public static void Main (string[] args)
+    {
+        Console.WriteLine("Date test for: {0}", args[0]);
+
+        System.DateTime cdt = System.IO.File.GetCreationTime(args[0]);
+        System.DateTime wdt = System.IO.File.GetLastWriteTime(args[0]);
+        System.DateTime adt = System.IO.File.GetLastAccessTime(args[0]);
+
+        writeTime("Creation: ", cdt);
+        writeTime("Write   : ", wdt);
+        writeTime("Access  : ", adt);
+
+        cdt = cdt.AddSeconds(10);
+        cdt = cdt.AddMilliseconds(1);
+
+        wdt = wdt.AddSeconds(20);
+        wdt = wdt.AddMilliseconds(1);
+
+        adt = adt.AddSeconds(30);
+        adt = adt.AddMilliseconds(1);
+
+        Console.WriteLine("");
+        writeTime("Creation: ", cdt);
+        writeTime("Write   : ", wdt);
+        writeTime("Access  : ", adt);
+
+        System.IO.File.SetCreationTime(args[0], cdt);
+        System.IO.File.SetLastWriteTime(args[0], wdt);
+        System.IO.File.SetLastAccessTime(args[0], adt);
+
+        cdt = System.IO.File.GetCreationTime(args[0]);
+        wdt = System.IO.File.GetLastWriteTime(args[0]);
+        adt = System.IO.File.GetLastAccessTime(args[0]);
+
+        Console.WriteLine("");
+        writeTime("Creation: ", cdt);
+        writeTime("Write   : ", wdt);
+        writeTime("Access  : ", adt);
+    }
+}