-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Directory.Delete: prefer DirectoryNotFoundException over UnauthorizedAccess IOException. #62396
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
…Access IOException.
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -497,8 +497,14 @@ private static bool RemoveEmptyDirectory(string fullPath, bool topLevel = false, | |
| case Interop.Error.EACCES: | ||
| case Interop.Error.EPERM: | ||
| case Interop.Error.EROFS: | ||
| // Prefer throwing DirectoryNotFoundException over UnauthorizedAccess IOException. | ||
| if (topLevel && !DirectoryExists(fullPath, out Interop.ErrorInfo existErr) && existErr.Error == Interop.Error.ENOENT) | ||
| { | ||
| throw Interop.GetExceptionForIoErrno(Interop.Error.ENOENT.Info(), fullPath, isDirectory: true); | ||
| } | ||
| throw new IOException(SR.Format(SR.UnauthorizedAccess_IODenied_Path, fullPath)); | ||
tmds marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| case Interop.Error.EISDIR: | ||
| throw new IOException(SR.Format(SR.UnauthorizedAccess_IODenied_Path, fullPath)); // match Win32 exception | ||
| throw new IOException(SR.Format(SR.UnauthorizedAccess_IODenied_Path, fullPath)); | ||
|
||
| case Interop.Error.ENOENT: | ||
| // When we're recursing, don't throw for items that go missing. | ||
| if (!topLevel) | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.