MonoIOError error;
if (!MonoIO.ExistsDirectory (wildpath, out error)) {
if (error == MonoIOError.ERROR_SUCCESS) {
- MonoIOError file_error;
- if (MonoIO.ExistsFile (wildpath, out file_error)) {
- stop = true;
- return wildpath;
- }
+ MonoIOError file_error;
+ if (MonoIO.ExistsFile (wildpath, out file_error))
+ throw new IOException ("The directory name is invalid.");
}
if (error != MonoIOError.ERROR_PATH_NOT_FOUND)
HANDLE find_handle;
GPtrArray *names;
gchar *utf8_path, *utf8_result, *full_name;
+ gint32 attributes;
MONO_ARCH_SAVE_REGS;
domain = mono_domain_get ();
mask = convert_attrs (mask);
+ attributes = get_file_attributes (mono_string_chars (path));
+ if (attributes != -1) {
+ if ((attributes & FILE_ATTRIBUTE_DIRECTORY) == 0) {
+ *error = ERROR_INVALID_NAME;
+ return (NULL);
+ }
+ } else {
+ *error = GetLastError ();
+ return (NULL);
+ }
- find_handle = FindFirstFile (mono_string_chars (path_with_pattern),
- &data);
+ find_handle = FindFirstFile (mono_string_chars (path_with_pattern), &data);
if (find_handle == INVALID_HANDLE_VALUE) {
gint32 find_error = GetLastError ();