Skip to content

InMemoryDirectoryInfo constructor not recognizing root #93107

Closed
@AnakinRaW

Description

@AnakinRaW

Description

Hi,

so unless i'm totally overseeing something here, the behavior of the InMemoryDirectoryInfo constructor irritates me a lot.
It seems that the parameter rootDir is not acutally used to resolve relative path.

The documentation however states this:

param files: Collection of file names. If relative paths rootDir will be prepended to the paths.

Reproduction Steps

See the following code:

var files = new List<string>{"Test.txt", "New/../Test.txt", "new/test.txt"};
var fs = new InMemoryDirectoryInfo("x:/", files);
var i = fs.EnumerateFileSystemInfos().ToList();

Expected behavior

expected result of i is a list containing 3 items of the following file names:

{"x:/test.txt", "x:/test.txt", "x:/new/test.txt"}

Actual behavior

The actual result is empty.
In the debugger you can also see that the relative paths have been resolved to the applications current directory (so something like c:/dev/app/bin/debug/test.txt)

Regression?

No response

Known Workarounds

No response

Configuration

No response

Other information

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions