当调用 DirectoryInfo.GetDirectories(。)上它指向一个有效的文件夹(不包括驱动器根)一个DirectoryInfo类的实例,结果是一个DirectoryInfo的数组,其第一个(也是唯一一个)元素指向一个无效的目录名称相同的本身,本身下方。
When calling DirectoryInfo.GetDirectories(".") on an instance of a DirectoryInfo class which points to a valid folder (excluding drive roots), the result is a DirectoryInfo array whose first (and only) element points to a invalid directory named the same as itself, below itself.
例如:
static void Main(string[] args)
{
DirectoryInfo di = new DirectoryInfo("c:temp");
DirectoryInfo[] dis = di.GetDirectories(".");
Console.WriteLine(dis[0].FullName);
}
打印出一个不存在的目录:
Prints out a non-existent directory:
c:temptemp
据我所知,在Windows中,一个。指当前目录。这或许可以被接受我,如果该方法返回C: TEMP,但返回假的子目录具有相同的名称似乎是绝对错误的行为。
I understand that in Windows, a "." refers to the current directory. That might be acceptable to me if the method returned "c:temp", but returning a fake subdirectory with the same name seems like absolutely the wrong behavior.
我应该可以断言,任何DirectoryInfo对象返回这个函数确实存在....吧?!
我反编译使用.net反射的类,但它导致了这种方法
I decompiled the class using .NET Reflector, but it leads to this method
internal static string[] InternalGetFileDirectoryNames(string path, string userPathOriginal, string searchPattern, bool includeFiles, bool includeDirs, SearchOption searchOption)"
这是一个野兽,我不喜欢通过逻辑在我的头上走。这显然是一个错误恕我直言。
Which is a BEAST and I don't feel like walking through the logic in my head. It's clearly a bug IMHO.
仅供参考 - 一个*为预期的工作,有人问前
FYI - a "*" works as expected, before someone asks.
推荐答案
我可以证实你说的话,并不能看到任何合理的解释吧,所以我投票的错误。
I can confirm what you say, and can't see any rational explanation for it, so I'm voting BUG.
我觉得这样很好,我其提交来微软
I think so as well, I submitted it to Microsoft
相关推荐
最新文章