static void DumpFile(string full_path, NtFile root, int recusive_depth, bool no_files) { try { if (!_walked.Add(full_path)) { return; } using (NtFile file = OpenFile(full_path, root)) { CheckAccess(full_path, file); if (file.IsDirectory && recusive_depth > 0) { IEnumerable <FileDirectoryEntry> dir_entries = file.QueryDirectoryInfo(null, FileTypeMask.All).OrderBy(d => d.FileName); if (!no_files) { foreach (string file_name in dir_entries.Where(d => !d.IsDirectory).Select(d => d.FileName)) { DumpFile(Path.Combine(full_path, file_name), file, recusive_depth - 1, no_files); } } foreach (string file_name in dir_entries.Where(d => d.IsDirectory).Select(d => d.FileName)) { DumpFile(Path.Combine(full_path, file_name), file, recusive_depth - 1, no_files); } } } } catch (Exception ex) { if (!_quiet) { Console.Error.WriteLine("Error dumping file {0} {1}", full_path, ex.Message); } } }