Bug 3783 - DirectoryInfo.GetDirectories with the SearchOption.AllDirectories parameter set doesn't work
Summary: DirectoryInfo.GetDirectories with the SearchOption.AllDirectories parameter s...
Alias: None
Product: Class Libraries
Classification: Mono
Component: mscorlib ()
Version: 2.10.x
Hardware: PC Linux
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
Depends on:
Reported: 2012-03-07 07:14 UTC by Mathias
Modified: 2012-10-30 05:18 UTC (History)
1 user (show)

Is this bug a regression?: ---
Last known good build:

Source file showing the error (848 bytes, text/plain)
2012-03-07 07:14 UTC, Mathias

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report on GitHub or Developer Community with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:

Description Mathias 2012-03-07 07:14:01 UTC
Created attachment 1468 [details]
Source file showing the error

If I search for subdirectories in a tree with the DirectoryInfo.GetDirectories() method and SearchOption.AllDirectories set, it simply doesn't work.
My attached test file creates a directory tree in /tmp. Searching for a subdirectory on the second level with DirectoryInfo.GetDirectories() fails, using the corresponding method Directory.GetSubDirectories works as expected.
The output of test.exe is

Directories found with DirectoryInfo: 0
Directories found with Directory: 1

I have look through the source code of DirectoryInfo.cs on github and found that, while DirectoryInfo.GetDirectories(string searchpattern) simply calls the corresponding method in Directory, DirectoryInfo.GetDirectories(string searchpattern, SearchOption searchOption) tries to re-implement this feature in a very weird and non-working way.
I have created a patch in github, which is more or less a copy/paste of DirectoryInfo.GetDirectories(string searchpattern):

Comment 1 Mathias 2012-10-30 05:18:50 UTC
The bugfix has been merged to the master branch by Marek Safar yesterday: