Browse Source

* File.cs: In 2.0 profile, File.Get****Time(Utc) should not throw
IOException if specified path does not exist. Fixes bug #77641.
* FileTest.cs: In 2.0 profile, no longer expect IOException when path to
non-existing directory or file is specified in Get***Time(Utc) methods
(bug #77641). Renamed tests and removed trailing tabs. Removed
duplicate test. Fixed GetLastWriteTime(Utc) tests that used
GetLastAccessTime(Utc) instead of GetLastWriteTime(Utc).
* DirectoryTest.cs: No longer expect IOException when path to
non-existing directory or file is specified in Get***Time(Utc) methods
(bug #77641).

svn path=/trunk/mcs/; revision=57338

Gert Driesen 20 years ago
parent
commit
06a833ea77

+ 5 - 0
mcs/class/corlib/System.IO/ChangeLog

@@ -1,3 +1,8 @@
+2006-02-27  Gert Driesen  <[email protected]>
+
+	* File.cs: In 2.0 profile, File.Get****Time(Utc) should not throw
+	IOException if specified path does not exist. Fixes bug #77641.
+
 2006-02-26  Gert Driesen  <[email protected]>
 
 	* FileStream.cs: To match MSFT, ignore FileShare.Inheritable on 2.0

+ 35 - 4
mcs/class/corlib/System.IO/File.cs

@@ -216,9 +216,17 @@ namespace System.IO
 			MonoIOStat stat;
 			MonoIOError error;
 			CheckPathExceptions (path);
-			
-			if (!MonoIO.GetFileStat (path, out stat, out error))
+
+			if (!MonoIO.GetFileStat (path, out stat, out error)) {
+#if NET_2_0
+				if (error == MonoIOError.ERROR_PATH_NOT_FOUND || error == MonoIOError.ERROR_FILE_NOT_FOUND)
+					return _defaultLocalFileTime;
+				else
+					throw new IOException (path);
+#else
 				throw new IOException (path);
+#endif
+			}
 			return DateTime.FromFileTime (stat.CreationTime);
 		}
 
@@ -233,8 +241,16 @@ namespace System.IO
 			MonoIOError error;
 			CheckPathExceptions (path);
 
-			if (!MonoIO.GetFileStat (path, out stat, out error))
+			if (!MonoIO.GetFileStat (path, out stat, out error)) {
+#if NET_2_0
+				if (error == MonoIOError.ERROR_PATH_NOT_FOUND || error == MonoIOError.ERROR_FILE_NOT_FOUND)
+					return _defaultLocalFileTime;
+				else
+					throw new IOException (path);
+#else
 				throw new IOException (path);
+#endif
+			}
 			return DateTime.FromFileTime (stat.LastAccessTime);
 		}
 
@@ -249,8 +265,16 @@ namespace System.IO
 			MonoIOError error;
 			CheckPathExceptions (path);
 
-			if (!MonoIO.GetFileStat (path, out stat, out error))
+			if (!MonoIO.GetFileStat (path, out stat, out error)) {
+#if NET_2_0
+				if (error == MonoIOError.ERROR_PATH_NOT_FOUND || error == MonoIOError.ERROR_FILE_NOT_FOUND)
+					return _defaultLocalFileTime;
+				else
+					throw new IOException (path);
+#else
 				throw new IOException (path);
+#endif
+			}
 			return DateTime.FromFileTime (stat.LastWriteTime);
 		}
 
@@ -411,6 +435,11 @@ namespace System.IO
 		#endregion
 
 #if NET_2_0
+		static File() {
+			_defaultLocalFileTime = new DateTime (1601, 1, 1);
+			_defaultLocalFileTime = _defaultLocalFileTime.ToLocalTime ();
+		}
+
 		//
 		// The documentation for this method is most likely wrong, it
 		// talks about doing a "binary read", but the remarks say
@@ -461,6 +490,8 @@ namespace System.IO
 				sw.Write (contents);
 			}
 		}
+
+		private static readonly DateTime _defaultLocalFileTime;
 #endif
 	}
 }

+ 11 - 0
mcs/class/corlib/Test/System.IO/ChangeLog

@@ -1,3 +1,14 @@
+2006-02-27  Gert Driesen  <[email protected]>
+
+	* FileTest.cs: In 2.0 profile, no longer expect IOException when path to
+	non-existing directory or file is specified in Get***Time(Utc) methods
+	(bug #77641). Renamed tests and removed trailing tabs. Removed
+	duplicate test. Fixed GetLastWriteTime(Utc) tests that used
+	GetLastAccessTime(Utc) instead of GetLastWriteTime(Utc).
+	* DirectoryTest.cs: No longer expect IOException when path to 
+	non-existing directory or file is specified in Get***Time(Utc) methods
+	(bug #77641).	
+
 2006-02-26  Gert Driesen  <[email protected]>
 
 	* FileStreamTest.cs: Fixed tests for invalid share value to pass on

+ 90 - 21
mcs/class/corlib/Test/System.IO/DirectoryTest.cs

@@ -214,13 +214,25 @@ public class DirectoryTest : Assertion {
 	}
 	
 	[Test]
+#if !NET_2_0
 	[ExpectedException(typeof(IOException))]
-	public void GetCreationTimeException3 ()
+#endif
+	public void GetCreationTimeException_NonExistingPath ()
 	{
 		string path = TempFolder + DSC + "DirectoryTest.GetCreationTime.1";
 		DeleteDirectory (path);
 		try {
-			Directory.GetCreationTime (path);
+			DateTime time = Directory.GetCreationTime (path);
+
+#if NET_2_0
+			DateTime expectedTime = (new DateTime (1601, 1, 1)).ToLocalTime ();
+			Assertion.AssertEquals ("#1", expectedTime.Year, time.Year);
+			Assertion.AssertEquals ("#2", expectedTime.Month, time.Month);
+			Assertion.AssertEquals ("#3", expectedTime.Day, time.Day);
+			Assertion.AssertEquals ("#4", expectedTime.Hour, time.Hour);
+			Assertion.AssertEquals ("#5", expectedTime.Second, time.Second);
+			Assertion.AssertEquals ("#6", expectedTime.Millisecond, time.Millisecond);
+#endif
 		} finally {
 			DeleteDirectory (path);
 		}
@@ -255,14 +267,25 @@ public class DirectoryTest : Assertion {
 	}
 	
 	[Test]
-	[ExpectedException(typeof(IOException))]
-	public void GetCreationTimeUtcException3 ()
+#if !NET_2_0
+	[ExpectedException (typeof (IOException))]
+#endif
+	public void GetCreationTimeUtc_NonExistingPath ()
 	{
 		string path = TempFolder + DSC + "DirectoryTest.GetCreationTimeUtc.1";
 		DeleteDirectory (path);
 		
 		try {
-			Directory.GetCreationTimeUtc (path);
+			DateTime time = Directory.GetCreationTimeUtc (path);
+
+#if NET_2_0
+			Assertion.AssertEquals ("#1", 1601, time.Year);
+			Assertion.AssertEquals ("#2", 1, time.Month);
+			Assertion.AssertEquals ("#3", 1, time.Day);
+			Assertion.AssertEquals ("#4", 0, time.Hour);
+			Assertion.AssertEquals ("#5", 0, time.Second);
+			Assertion.AssertEquals ("#6", 0, time.Millisecond);
+#endif
 		} finally {
 			DeleteDirectory (path);
 		}
@@ -297,14 +320,26 @@ public class DirectoryTest : Assertion {
 	}
 	
 	[Test]
-	[ExpectedException(typeof(IOException))]
-	public void GetLastAccessTimeException3 ()
+#if !NET_2_0
+	[ExpectedException (typeof (IOException))]
+#endif
+	public void GetLastAccessTime_NonExistingPath ()
 	{
 		string path = TempFolder + DSC + "DirectoryTest.GetLastAccessTime.1";
 		DeleteDirectory (path);
 		
 		try {
-			Directory.GetLastAccessTime (path);
+			DateTime time = Directory.GetLastAccessTime (path);
+
+#if NET_2_0
+			DateTime expectedTime = (new DateTime (1601, 1, 1)).ToLocalTime ();
+			Assertion.AssertEquals ("#1", expectedTime.Year, time.Year);
+			Assertion.AssertEquals ("#2", expectedTime.Month, time.Month);
+			Assertion.AssertEquals ("#3", expectedTime.Day, time.Day);
+			Assertion.AssertEquals ("#4", expectedTime.Hour, time.Hour);
+			Assertion.AssertEquals ("#5", expectedTime.Second, time.Second);
+			Assertion.AssertEquals ("#6", expectedTime.Millisecond, time.Millisecond);
+#endif
 		} finally {
 			DeleteDirectory (path);
 		}
@@ -339,13 +374,24 @@ public class DirectoryTest : Assertion {
 	}
 	
 	[Test]
-	[ExpectedException(typeof(IOException))]
-	public void GetLastAccessTimeUtcException3 ()
+#if !NET_2_0
+	[ExpectedException (typeof (IOException))]
+#endif
+	public void GetLastAccessTimeUtc_NonExistingPath ()
 	{
 		string path = TempFolder + DSC + "DirectoryTest.GetLastAccessTimeUtc.1";
 		DeleteDirectory (path);
 		try {
-			Directory.GetLastAccessTimeUtc (path);
+			DateTime time = Directory.GetLastAccessTimeUtc (path);
+
+#if NET_2_0
+			Assertion.AssertEquals ("#1", 1601, time.Year);
+			Assertion.AssertEquals ("#2", 1, time.Month);
+			Assertion.AssertEquals ("#3", 1, time.Day);
+			Assertion.AssertEquals ("#4", 0, time.Hour);
+			Assertion.AssertEquals ("#5", 0, time.Second);
+			Assertion.AssertEquals ("#6", 0, time.Millisecond);
+#endif
 		} finally {
 			DeleteDirectory (path);
 		}
@@ -380,13 +426,25 @@ public class DirectoryTest : Assertion {
 	}
 	
 	[Test]
-	[ExpectedException(typeof(IOException))]
-	public void GetLastWriteTimeException3 ()
+#if !NET_2_0
+	[ExpectedException (typeof (IOException))]
+#endif
+	public void GetLastWriteTime_NonExistingPath ()
 	{
 		string path = TempFolder + DSC + "DirectoryTest.GetLastWriteTime.1";
 		DeleteDirectory (path);
 		try {
-			Directory.GetLastWriteTime (path);
+			DateTime time = Directory.GetLastWriteTime (path);
+
+#if NET_2_0
+			DateTime expectedTime = (new DateTime (1601, 1, 1)).ToLocalTime ();
+			Assertion.AssertEquals ("#1", expectedTime.Year, time.Year);
+			Assertion.AssertEquals ("#2", expectedTime.Month, time.Month);
+			Assertion.AssertEquals ("#3", expectedTime.Day, time.Day);
+			Assertion.AssertEquals ("#4", expectedTime.Hour, time.Hour);
+			Assertion.AssertEquals ("#5", expectedTime.Second, time.Second);
+			Assertion.AssertEquals ("#6", expectedTime.Millisecond, time.Millisecond);
+#endif
 		} finally {
 			DeleteDirectory (path);
 		}
@@ -417,17 +475,28 @@ public class DirectoryTest : Assertion {
 	[ExpectedException(typeof(ArgumentException))]	
 	public void GetLastWriteTimeUtcException2 ()
 	{
-		Directory.GetLastAccessTimeUtc ("");
+		Directory.GetLastWriteTimeUtc ("");
 	}
 	
 	[Test]
-	[ExpectedException(typeof(IOException))]
-	public void GetLastWriteTimeUtcException3 ()
+#if !NET_2_0
+	[ExpectedException (typeof (IOException))]
+#endif
+	public void GetLastWriteTimeUtc_NonExistingPath ()
 	{
 		string path = TempFolder + DSC + "DirectoryTest.GetLastWriteTimeUtc.1";
 		DeleteDirectory (path);
 		try {
-			Directory.GetLastAccessTimeUtc (path);
+			DateTime time = Directory.GetLastWriteTimeUtc (path);
+
+#if NET_2_0
+			Assertion.AssertEquals ("#1", 1601, time.Year);
+			Assertion.AssertEquals ("#2", 1, time.Month);
+			Assertion.AssertEquals ("#3", 1, time.Day);
+			Assertion.AssertEquals ("#4", 0, time.Hour);
+			Assertion.AssertEquals ("#5", 0, time.Second);
+			Assertion.AssertEquals ("#6", 0, time.Millisecond);
+#endif
 		} finally {
 			DeleteDirectory (path);
 		}
@@ -438,14 +507,14 @@ public class DirectoryTest : Assertion {
 	[ExpectedException(typeof(ArgumentException))]	
 	public void GetLastWriteTimeUtcException4 ()
 	{
-		Directory.GetLastAccessTimeUtc ("    ");
+		Directory.GetLastWriteTimeUtc ("    ");
 	}
 
 	[Test]
 	[ExpectedException(typeof(ArgumentException))]	
 	public void GetLastWriteTimeUtcException5 ()
 	{
-		Directory.GetLastAccessTimeUtc (Path.InvalidPathChars [0].ToString ());
+		Directory.GetLastWriteTimeUtc (Path.InvalidPathChars[0].ToString ());
 	}
 
 	[Test]
@@ -969,7 +1038,7 @@ public class DirectoryTest : Assertion {
 //			DeleteDirectory (path);
 //		}
 //	}
-
+
 	[Test]
 	[ExpectedException(typeof(ArgumentNullException))]
 	public void SetCreationTimeException1 ()

+ 122 - 66
mcs/class/corlib/Test/System.IO/FileTest.cs

@@ -601,19 +601,6 @@ namespace MonoTests.System.IO
                 	}
 		}
 
-                [Test]
-                [ExpectedException(typeof(IOException))]
-                public void TestGetCreationTimeException ()
-                {
-                        // Test nonexistent files
-                        string path2 = TempFolder + Path.DirectorySeparatorChar + "filedoesnotexist";
-			DeleteFile (path2);
-                        // should throw an exception
-                        File.GetCreationTime (path2);
-                }
-                
-
-
 		// Setting the creation time on Unix is not possible
                 [Test]
                 public void CreationTime ()
@@ -768,211 +755,280 @@ namespace MonoTests.System.IO
 		}
 	
 		[Test]
+#if !NET_2_0
 		[ExpectedException(typeof(IOException))]
-		public void GetCreationTimeException3 ()
+#endif
+		public void GetCreationTime_NonExistingPath ()
 		{
-                        string path = TempFolder + Path.DirectorySeparatorChar + "GetCreationTimeException3";                	
-			DeleteFile (path);		
-			File.GetCreationTime (path);
+			string path = TempFolder + Path.DirectorySeparatorChar + "GetCreationTimeException3";
+			DeleteFile (path);
+			DateTime time = File.GetCreationTime (path);
+
+#if NET_2_0
+			DateTime expectedTime = (new DateTime (1601, 1, 1)).ToLocalTime ();
+			Assertion.AssertEquals ("#1", expectedTime.Year, time.Year);
+			Assertion.AssertEquals ("#2", expectedTime.Month, time.Month);
+			Assertion.AssertEquals ("#3", expectedTime.Day, time.Day);
+			Assertion.AssertEquals ("#4", expectedTime.Hour, time.Hour);
+			Assertion.AssertEquals ("#5", expectedTime.Second, time.Second);
+			Assertion.AssertEquals ("#6", expectedTime.Millisecond, time.Millisecond);
+#endif
 		}
 
 		[Test]
-		[ExpectedException(typeof(ArgumentException))]	
+		[ExpectedException(typeof(ArgumentException))]
 		public void GetCreationTimeException4 ()
 		{
 			File.GetCreationTime ("    ");
 		}
 
 		[Test]
-		[ExpectedException(typeof(ArgumentException))]	
+		[ExpectedException(typeof(ArgumentException))]
 		public void GetCreationTimeException5 ()
 		{
 			File.GetCreationTime (Path.InvalidPathChars [0].ToString ());
 		}
 
 		[Test]
-		[ExpectedException(typeof(ArgumentNullException))]	
+		[ExpectedException(typeof(ArgumentNullException))]
 		public void GetCreationTimeUtcException1 ()
 		{
 			File.GetCreationTimeUtc (null as string);
 		}
 
 		[Test]
-		[ExpectedException(typeof(ArgumentException))]	
+		[ExpectedException(typeof(ArgumentException))]
 		public void GetCreationTimeUtcException2 ()
 		{
 			File.GetCreationTimeUtc ("");
 		}
 	
 		[Test]
-		[ExpectedException(typeof(IOException))]
-		public void GetCreationTimeUtcException3 ()
+#if !NET_2_0
+		[ExpectedException (typeof (IOException))]
+#endif
+		public void GetCreationTimeUtc_NonExistingPath ()
 		{
-                        string path = TempFolder + Path.DirectorySeparatorChar + "GetCreationTimeUtcException3";                	
-			DeleteFile (path);		
-			File.GetCreationTimeUtc (path);
+			string path = TempFolder + Path.DirectorySeparatorChar + "GetCreationTimeUtcException3";
+			DeleteFile (path);
+			DateTime time = File.GetCreationTimeUtc (path);
+
+#if NET_2_0
+			Assertion.AssertEquals ("#1", 1601, time.Year);
+			Assertion.AssertEquals ("#2", 1, time.Month);
+			Assertion.AssertEquals ("#3", 1, time.Day);
+			Assertion.AssertEquals ("#4", 0, time.Hour);
+			Assertion.AssertEquals ("#5", 0, time.Second);
+			Assertion.AssertEquals ("#6", 0, time.Millisecond);
+#endif
 		}
 
 		[Test]
-		[ExpectedException(typeof(ArgumentException))]	
+		[ExpectedException(typeof(ArgumentException))]
 		public void GetCreationTimeUtcException4 ()
 		{
 			File.GetCreationTimeUtc ("    ");
 		}
 
 		[Test]
-		[ExpectedException(typeof(ArgumentException))]	
+		[ExpectedException(typeof(ArgumentException))]
 		public void GetCreationTimeUtcException5 ()
 		{
 			File.GetCreationTime (Path.InvalidPathChars [0].ToString ());
 		}
 
 		[Test]
-		[ExpectedException(typeof(ArgumentNullException))]	
+		[ExpectedException(typeof(ArgumentNullException))]
 		public void GetLastAccessTimeException1 ()
 		{
 			File.GetLastAccessTime (null as string);
 		}
 
 		[Test]
-		[ExpectedException(typeof(ArgumentException))]	
+		[ExpectedException(typeof(ArgumentException))]
 		public void GetLastAccessTimeException2 ()
 		{
 			File.GetLastAccessTime ("");
 		}
 	
 		[Test]
-		[ExpectedException(typeof(IOException))]
-		public void GetLastAccessTimeException3 ()
+#if !NET_2_0
+		[ExpectedException (typeof (IOException))]
+#endif
+		public void GetLastAccessTime_NonExistingPath ()
 		{
-                        string path = TempFolder + Path.DirectorySeparatorChar + "GetLastAccessTimeException3";                	
-			DeleteFile (path);		
-			File.GetLastAccessTime (path);
+			string path = TempFolder + Path.DirectorySeparatorChar + "GetLastAccessTimeException3";
+			DeleteFile (path);
+			DateTime time = File.GetLastAccessTime (path);
+
+#if NET_2_0
+			DateTime expectedTime = (new DateTime (1601, 1, 1)).ToLocalTime ();
+			Assertion.AssertEquals ("#1", expectedTime.Year, time.Year);
+			Assertion.AssertEquals ("#2", expectedTime.Month, time.Month);
+			Assertion.AssertEquals ("#3", expectedTime.Day, time.Day);
+			Assertion.AssertEquals ("#4", expectedTime.Hour, time.Hour);
+			Assertion.AssertEquals ("#5", expectedTime.Second, time.Second);
+			Assertion.AssertEquals ("#6", expectedTime.Millisecond, time.Millisecond);
+#endif
 		}
 
 		[Test]
-		[ExpectedException(typeof(ArgumentException))]	
+		[ExpectedException(typeof(ArgumentException))]
 		public void GetLastAccessTimeException4 ()
 		{
 			File.GetLastAccessTime ("    ");
 		}
 
 		[Test]
-		[ExpectedException(typeof(ArgumentException))]	
+		[ExpectedException(typeof(ArgumentException))]
 		public void GetLastAccessTimeException5 ()
 		{
 			File.GetLastAccessTime (Path.InvalidPathChars [0].ToString ());
 		}
 
 		[Test]
-		[ExpectedException(typeof(ArgumentNullException))]	
+		[ExpectedException(typeof(ArgumentNullException))]
 		public void GetLastAccessTimeUtcException1 ()
 		{
 			File.GetLastAccessTimeUtc (null as string);
 		}
 
 		[Test]
-		[ExpectedException(typeof(ArgumentException))]	
+		[ExpectedException(typeof(ArgumentException))]
 		public void GetLastAccessTimeUtcException2 ()
 		{
 			File.GetLastAccessTimeUtc ("");
 		}
 	
 		[Test]
-		[ExpectedException(typeof(IOException))]
-		public void GetLastAccessTimeUtcException3 ()
+#if !NET_2_0
+		[ExpectedException (typeof (IOException))]
+#endif
+		public void GetLastAccessTimeUtc_NonExistingPath ()
 		{
-                        string path = TempFolder + Path.DirectorySeparatorChar + "GetLastAccessTimeUtcException3";                	
-			DeleteFile (path);			
-			File.GetLastAccessTimeUtc (path);
+			string path = TempFolder + Path.DirectorySeparatorChar + "GetLastAccessTimeUtcException3";
+			DeleteFile (path);
+			DateTime time = File.GetLastAccessTimeUtc (path);
+
+#if NET_2_0
+			Assertion.AssertEquals ("#1", 1601, time.Year);
+			Assertion.AssertEquals ("#2", 1, time.Month);
+			Assertion.AssertEquals ("#3", 1, time.Day);
+			Assertion.AssertEquals ("#4", 0, time.Hour);
+			Assertion.AssertEquals ("#5", 0, time.Second);
+			Assertion.AssertEquals ("#6", 0, time.Millisecond);
+#endif
 		}
 
 		[Test]
-		[ExpectedException(typeof(ArgumentException))]	
+		[ExpectedException(typeof(ArgumentException))]
 		public void GetLastAccessTimeUtcException4 ()
 		{
 			File.GetLastAccessTimeUtc ("    ");
 		}
 
 		[Test]
-		[ExpectedException(typeof(ArgumentException))]	
+		[ExpectedException(typeof(ArgumentException))]
 		public void GetLastAccessTimeUtcException5 ()
 		{
 			File.GetLastAccessTimeUtc (Path.InvalidPathChars [0].ToString ());
 		}
 
 		[Test]
-		[ExpectedException(typeof(ArgumentNullException))]	
+		[ExpectedException(typeof(ArgumentNullException))]
 		public void GetLastWriteTimeException1 ()
 		{
 			File.GetLastWriteTime (null as string);
 		}
 
 		[Test]
-		[ExpectedException(typeof(ArgumentException))]	
+		[ExpectedException(typeof(ArgumentException))]
 		public void GetLastWriteTimeException2 ()
 		{
 			File.GetLastWriteTime ("");
 		}
 	
 		[Test]
-		[ExpectedException(typeof(IOException))]
-		public void GetLastWriteTimeException3 ()
+#if !NET_2_0
+		[ExpectedException (typeof (IOException))]
+#endif
+		public void GetLastWriteTime_NonExistingPath ()
 		{
-                        string path = TempFolder + Path.DirectorySeparatorChar + "GetLastAccessTimeUtcException3";                	
-			DeleteFile (path);			
-			File.GetLastWriteTime (path);
+			string path = TempFolder + Path.DirectorySeparatorChar + "GetLastAccessTimeUtcException3";
+			DeleteFile (path);
+			DateTime time = File.GetLastWriteTime (path);
+
+#if NET_2_0
+			DateTime expectedTime = (new DateTime (1601, 1, 1)).ToLocalTime ();
+			Assertion.AssertEquals ("#1", expectedTime.Year, time.Year);
+			Assertion.AssertEquals ("#2", expectedTime.Month, time.Month);
+			Assertion.AssertEquals ("#3", expectedTime.Day, time.Day);
+			Assertion.AssertEquals ("#4", expectedTime.Hour, time.Hour);
+			Assertion.AssertEquals ("#5", expectedTime.Second, time.Second);
+			Assertion.AssertEquals ("#6", expectedTime.Millisecond, time.Millisecond);
+#endif
 		}
 
 		[Test]
-		[ExpectedException(typeof(ArgumentException))]	
+		[ExpectedException(typeof(ArgumentException))]
 		public void GetLastWriteTimeException4 ()
 		{
 			File.GetLastWriteTime ("    ");
 		}
 
 		[Test]
-		[ExpectedException(typeof(ArgumentException))]	
+		[ExpectedException(typeof(ArgumentException))]
 		public void GetLastWriteTimeException5 ()
 		{
 			File.GetLastWriteTime (Path.InvalidPathChars [0].ToString ());
 		}
 
 		[Test]
-		[ExpectedException(typeof(ArgumentNullException))]	
+		[ExpectedException(typeof(ArgumentNullException))]
 		public void GetLastWriteTimeUtcException1 ()
 		{
 			File.GetLastWriteTimeUtc (null as string);
 		}
 
 		[Test]
-		[ExpectedException(typeof(ArgumentException))]	
+		[ExpectedException(typeof(ArgumentException))]
 		public void GetLastWriteTimeUtcException2 ()
 		{
-			File.GetLastAccessTimeUtc ("");
+			File.GetLastWriteTimeUtc ("");
 		}
 	
 		[Test]
-		[ExpectedException(typeof(IOException))]
-		public void GetLastWriteTimeUtcException3 ()
+#if !NET_2_0
+		[ExpectedException (typeof (IOException))]
+#endif
+		public void GetLastWriteTimeUtc_NonExistingPath ()
 		{
-                        string path = TempFolder + Path.DirectorySeparatorChar + "GetLastWriteTimeUtcException3";
+			string path = TempFolder + Path.DirectorySeparatorChar + "GetLastWriteTimeUtcException3";
 			DeleteFile (path);
-			File.GetLastAccessTimeUtc (path);
+			DateTime time = File.GetLastWriteTimeUtc (path);
+
+#if NET_2_0
+			Assertion.AssertEquals ("#1", 1601, time.Year);
+			Assertion.AssertEquals ("#2", 1, time.Month);
+			Assertion.AssertEquals ("#3", 1, time.Day);
+			Assertion.AssertEquals ("#4", 0, time.Hour);
+			Assertion.AssertEquals ("#5", 0, time.Second);
+			Assertion.AssertEquals ("#6", 0, time.Millisecond);
+#endif
 		}
 
 		[Test]
-		[ExpectedException(typeof(ArgumentException))]	
+		[ExpectedException(typeof(ArgumentException))]
 		public void GetLastWriteTimeUtcException4 ()
 		{
-			File.GetLastAccessTimeUtc ("    ");
+			File.GetLastWriteTimeUtc ("    ");
 		}
 
 		[Test]
-		[ExpectedException(typeof(ArgumentException))]	
+		[ExpectedException(typeof(ArgumentException))]
 		public void GetLastWriteTimeUtcException5 ()
 		{
-			File.GetLastAccessTimeUtc (Path.InvalidPathChars [0].ToString ());
+			File.GetLastWriteTimeUtc (Path.InvalidPathChars [0].ToString ());
 		}		
 
 		[Test]