我正在 linux ubuntu 上尝试 Mono。文件枚举不适用于子目录。如果我使用 GetFiles() 它将起作用。我使用控制台来获取文件的输出,所以我不会得到枚举输出:
[Test]
public void NotImportentTest ()
{
Directory.CreateDirectory("test");
Directory.CreateDirectory("test/dings");
File.Create("test/dings/hallo").Close();
var curdir = Directory.GetCurrentDirectory();
var searchdir = new DirectoryInfo(curdir + "/test");
var files = searchdir.EnumerateFiles("*",SearchOption.AllDirectories);
foreach (var file in files)
{
Console.WriteLine("Enumerate:{0} in {1}\r\n", file, curdir);
}
foreach (var file in searchdir.GetFiles("*",SearchOption.AllDirectories))
{
Console.WriteLine("GetFiles:{0} in {1}\r\n", file, curdir);
}
}