Bug 5512 - System.IO.Directory.EnumerateDirectories fails to list all directories if CWD changes
Summary: System.IO.Directory.EnumerateDirectories fails to list all directories if CWD...
Status: RESOLVED NORESPONSE
Alias: None
Product: Class Libraries
Classification: Mono
Component: System (show other bugs)
Version: 2.10.x
Hardware: PC Linux
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2012-06-04 16:24 UTC by Elisée Maurer
Modified: 2018-03-13 11:07 UTC (History)
3 users (show)

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

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:
Status:
RESOLVED NORESPONSE

Description Elisée Maurer 2012-06-04 16:24:28 UTC
Mono's System.IO.Directory.EnumerateDirectories doesn't list all directories in the specified (relative) path if the CWD changes during enumeration.

My guess is that the .NET version of System.IO.Directory.EnumerateDirectories() keeps a handle to the current working directory or maybe resolves the full path when called and Mono's version fails to do so, which makes it unable to keep enumerating directories if the CWD changes during enumeration.

I encountered this bug with the following code under Linux running Mono 2.10.:

  foreach( string strProjectDirectory in Directory.EnumerateDirectories( "Projects" ) )
  {
    // This method call changes the current working directory at some point
    DoSomethingWithProjectFolder( strProjectDirectory );

    // Other project folders never get enumerated
  }
Comment 1 Marek Safar 2012-06-15 10:09:42 UTC
I cannot reproduce the issue, my simple tests works

using System.IO;
using System;

class C
{
	public static void Main ()
	{
		foreach (var d in Directory.EnumerateDirectories ("/tmp/1", "*", SearchOption.AllDirectories))
		{
			Directory.SetCurrentDirectory ("/tmp");
			Console.WriteLine (d);
		}
	}
}
Comment 2 Marek Safar 2018-03-13 11:07:33 UTC
We have not received the requested information. If you are still experiencing this issue please provide all the requested information and reopen the bug report.

Thank you!