我有一个DirectoryInfo
对象,我打电话给GetDirectories("???")
。
根据MSDN,这应该返回名称中只有3个字符的所有目录。
在这个目录中我有5个子目录。其中4个有3个字符,1个有2个字符。这将不断返回其中的所有5个。这是.NET中的错误吗?
DirectoryInfo diBase = new DirectoryInfo(sProcessedPath);
DirectoryInfo[] diBaseDirList = diBase.GetDirectories("???");
foreach(DirectoryInfo diBaseDirItem in diBaseDirList)...
另外我发现如果你在powershell并调用dir(Get-ChildItem)???它返回正确的子文件夹列表。但在标准命令提示符dir ???也正在返回ax文件夹。
答案 0 :(得分:0)
所以我找到了答案。如果从程序中调用powershell,它将正确解析。 3个问号= 3个字符。
System.Management.Automation.PowerShell ps = System.Management.Automation.PowerShell.Create();
ps.AddCommand("Get-ChildItem");
ps.AddParameter("Path", sProcessedPath);
ps.AddParameter("Include", "???");
foreach (System.Management.Automation.PSObject result in ps.Invoke())
{
Console.WriteLine(result.Members["Name"].Value);
}
这不会打印出ax目录名称。显然,微软在powershell中修复了他们的错误。