I just stumbled upon an undocumented behavior of the GetFiles methods in System.IO.Directory.
Whenever the searchPattern parameter passed to the method contains a reserved Windows device name, such as "nul.*" or "aux.bmp", the method returns an array containing the name of a nonexisting file, like C:\Users\ft1\nul or D:\aux, etc.
I wonder if those device names have a special meaning it that context, like “.” or “..”, or if this is just a sort of bug. Anyway, that still seems pretty weird.
For example, this code snippet in C#:
string[] fileNames = Directory.GetFiles(@"C:\D:\..\..\...\", "con.txt");
foreach (string fileName in fileNames) Console.WriteLine(fileName);
prints
C:\D:\..\..\...\con
Any clues?
This is known. It is an operating system design regarding Naming Files, Paths, and Namespaces (Windows)
These are basically filename aliases (namespaces), so they always exist globally (in every folder). If you attempt to enumerate them, you’ll get them back because they do exist.