diff options
Diffstat (limited to 'mcs/class/corlib/System.IO/File.cs')
-rw-r--r-- | mcs/class/corlib/System.IO/File.cs | 64 |
1 files changed, 4 insertions, 60 deletions
diff --git a/mcs/class/corlib/System.IO/File.cs b/mcs/class/corlib/System.IO/File.cs index 3054a7c0909..ab5f506b6a8 100644 --- a/mcs/class/corlib/System.IO/File.cs +++ b/mcs/class/corlib/System.IO/File.cs @@ -36,7 +36,6 @@ // using System; -using System.Text; namespace System.IO { @@ -216,17 +215,9 @@ namespace System.IO MonoIOStat stat; MonoIOError error; CheckPathExceptions (path); - - 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 + + if (!MonoIO.GetFileStat (path, out stat, out error)) throw new IOException (path); -#endif - } return DateTime.FromFileTime (stat.CreationTime); } @@ -241,16 +232,8 @@ namespace System.IO MonoIOError error; CheckPathExceptions (path); - 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 + if (!MonoIO.GetFileStat (path, out stat, out error)) throw new IOException (path); -#endif - } return DateTime.FromFileTime (stat.LastAccessTime); } @@ -265,16 +248,8 @@ namespace System.IO MonoIOError error; CheckPathExceptions (path); - 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 + if (!MonoIO.GetFileStat (path, out stat, out error)) throw new IOException (path); -#endif - } return DateTime.FromFileTime (stat.LastWriteTime); } @@ -435,11 +410,6 @@ 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 @@ -466,32 +436,6 @@ namespace System.IO return result; } } - - public static string ReadAllText (string path) - { - return ReadAllText (path, Encoding.UTF8Unmarked); - } - - public static string ReadAllText (string path, Encoding enc) - { - using (StreamReader sr = new StreamReader (path, enc)) { - return sr.ReadToEnd (); - } - } - - public static void WriteAllText (string path, string contents) - { - WriteAllText (path, contents, Encoding.UTF8Unmarked); - } - - public static void WriteAllText (string path, string contents, Encoding enc) - { - using (StreamWriter sw = new StreamWriter (path, false, enc)) { - sw.Write (contents); - } - } - - private static readonly DateTime _defaultLocalFileTime; #endif } } |