public static void ScanMarkdownFiles(string workDir, Config configuration, ILog log) { log.Info("Scanning markdown files..."); FsPath destination = new FsPath(workDir, ".chapters"); List <Chapter> chapters = new List <Chapter>(10); string[] dirs = Directory.GetDirectories(workDir); string[] root = Directory.GetFiles(workDir, "*.md"); chapters.Add(new Chapter { Title = "Root", Files = SetFiles(root, workDir, configuration.TOCFile) }); foreach (var dir in dirs) { string[] files = Directory.GetFiles(dir, "*.md", SearchOption.AllDirectories); chapters.Add(new Chapter { Title = Path.GetFileName(dir), Files = SetFiles(files, dir, configuration.TOCFile) }); } log.Info("Writing .chapters file..."); destination.SerializeYaml(chapters, log); }