var projects = Find(baseDir, (v) => v.EndsWith(".csproj")); private List<string> Find(string baseDir, Func<string, bool> condition, List<string> list = null) { list = list ?? new List<string>(); var projects = Directory.GetFiles(baseDir).Where(v => condition(v)); list.AddRange(projects); foreach (var dir in Directory.GetDirectories(baseDir)) { Find(dir, condition, list); } return list; }
もっと手軽で汎用的な方法はないものか。DirectoryInfo の拡張で定義するのが良いのかな。