0

This is Windows 11 Pro (22000.2057).

enter image description here

Using this code:

var dir = new DirectoryInfo("E:\\Videos");
foreach (var sub in dir.GetDirectories())
{
$"'{sub.Name}'".Dump();

}

I can see why:

enter image description here

Attempting to navigate through explorer shows the contents of "Movies" for both folders. Trying to navigate to it through powershell shows:

enter image description here

How can I fix this?

Ian Newson
  • 545
  • 4
  • 18

1 Answers1

1

Make sure the entire path does not end with a space – trailing spaces are technically valid for names but stripped from paths. When accessing the directory itself, suffix it with an additional \.

Videos\Movies \

If it were a file, you could suffix it with the explicit NTFS stream name ::$DATA.

u1686_grawity
  • 452,512