dotnet / dotnet/dotnet-api-docs
Directory.EnumerateFiles and other EnumerateX methods either omit IOException or list it incorrectly
- Dominant language
- C#
- Stars
- 949
- Forks
- 1.7k
- Avg merge
- 3d 27m
- Merged PRs (30d)
- 49
Description
https://docs.microsoft.com/en-us/dotnet/api/system.io.directory.enumeratefiles?view=netframework-4.8 states that an `IOException` is thrown if the path in question is a filename.
https://docs.microsoft.com/en-us/dotnet/api/system.io.directoryinfo.enumeratefilesysteminfos?view=netframework-4.8 does not even mention that `IOException` can be thrown.
However, if we consult the Framework reference source for these methods we eventually get to https://referencesource.microsoft.com/#mscorlib/system/io/filesystemenumerable.cs,280 which leads to https://referencesource.microsoft.com/#mscorlib/system/io/__error.cs,187 which clearly demonstrates that when an unknown Win32 error is thrown from `FindFirstFile` (which the various `EnumerateX` methods wrap), an `IOException` **is** thrown.
The documentation, at least for the .NET Framework, should be updated to reflect this - I am not sure of the behaviour of .NET Core/.NET 5.0/6.0.
Contributor guide
Assessment
This issue has not been assessed yet.