[Mono-dev] Incorrect Directory.GetParent behavior

Gonzalo Paniagua Javier gonzalo at ximian.com
Tue Apr 25 20:51:52 EDT 2006


On Mon, 2006-04-24 at 12:20 -0400, Emery Conrad wrote:
> Hi there,
> 
> Directory.GetParent should return a DirectoryInfo for *both* full path
> names and relative path names. (See
> http://msdn2.microsoft.com/en-us/library/system.io.directory.getparent.aspx for microsoft doc). Here's the issue: currently, mono implements Directory.GetParent using new DirectoryInfo(Path.GetDirectoryName(path)), but Path.GetDirectoryName *does not* returns an absolute directory name for a relative path (it returns the String-based relative path information contained in the argument). So, when mono calls "new DirectoryInfo(relpath)" for some relative path, it works UNLESS the Path.GetDirectoryName() has return String.Emtpy (since this is the required behavior for this function for a relative path of something in the current directory).
> 
> The fix is to make the ctor for DirectoryInfo reset the argument to
> Directory.GetCurrentDirectory() when the argument is String.Emtpy.
> Diff is below.

The problem is that on MS, when you do 'new DirectoryInfo ("")' it
fails.

Can you provide a test case or a bug report through bugzilla that
reproduces the issue?

-Gonzalo





More information about the Mono-devel-list mailing list