dotnet / dotnet/dotnet-api-docs

Directory.EnumerateFiles and other EnumerateX methods either omit IOException or list it incorrectly

Open
#6,752 2 comments 1 reaction 0 assignees View on GitHub
area-System.IO Pri3 untriaged
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

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.