+2004-05-31 Atsushi Enomoto <atsushi@ximian.com>
+
+ * Directory.cs, File.cs : Fixed Exists() that raised
+ DirectoryNotFoundException. Quick fix for bug #59354.
+
2004-05-30 Sebastien Pouliot <sebastien@ximian.com>
* BinaryReader.cs: Added missing disposed check for most methods.
public static bool Exists (string path)
{
- if (path == null)
- return false;
+ try {
+ if (path == null)
+ return false;
- MonoIOError error;
- bool exists;
+ MonoIOError error;
+ bool exists;
- exists = MonoIO.ExistsDirectory (path, out error);
- if (error != MonoIOError.ERROR_SUCCESS &&
- error != MonoIOError.ERROR_PATH_NOT_FOUND) {
- throw MonoIO.GetException (path, error);
- }
+ exists = MonoIO.ExistsDirectory (path, out error);
+ if (error != MonoIOError.ERROR_SUCCESS &&
+ error != MonoIOError.ERROR_PATH_NOT_FOUND) {
+ throw MonoIO.GetException (path, error);
+ }
- return(exists);
+ return(exists);
+ } catch (Exception) {
+ return false;
+ }
}
public static DateTime GetLastAccessTime (string path)
public static bool Exists (string path)
{
- // For security reasons no exceptions are
- // thrown, only false is returned if there is
- // any problem with the path or permissions.
- // Minimizes what information can be
- // discovered by using this method.
- if (null == path || String.Empty == path.Trim()
- || path.IndexOfAny(Path.InvalidPathChars) >= 0) {
- return false;
- }
-
- MonoIOError error;
- bool exists;
+ try {
+ // For security reasons no exceptions are
+ // thrown, only false is returned if there is
+ // any problem with the path or permissions.
+ // Minimizes what information can be
+ // discovered by using this method.
+ if (null == path || String.Empty == path.Trim()
+ || path.IndexOfAny(Path.InvalidPathChars) >= 0) {
+ return false;
+ }
+
+ MonoIOError error;
+ bool exists;
- exists = MonoIO.ExistsFile (path, out error);
- if (error != MonoIOError.ERROR_SUCCESS &&
- error != MonoIOError.ERROR_FILE_NOT_FOUND) {
- throw MonoIO.GetException (path, error);
+ exists = MonoIO.ExistsFile (path, out error);
+ if (error != MonoIOError.ERROR_SUCCESS &&
+ error != MonoIOError.ERROR_FILE_NOT_FOUND) {
+ throw MonoIO.GetException (path, error);
+ }
+
+ return(exists);
+ } catch (Exception) {
+ return false;
}
-
- return(exists);
}
public static FileAttributes GetAttributes (string path)