private static void RecursiveGetParentDirectories(ParsedPath rootPath, ref List<DirectoryInfo> dirs) { DirectoryInfo dirInfo = new DirectoryInfo(rootPath.VolumeAndDirectory); DirectoryInfo [] dirInfos = dirInfo.GetDirectories(rootPath.FileAndExtension); dirs.AddRange(dirInfos); if (!rootPath.IsRootDirectory) { RecursiveGetParentDirectories(rootPath.MakeParentPath(), ref dirs); } }
private static void RecursiveGetParentFiles(ParsedPath rootPath, ref List<FileInfo> files) { DirectoryInfo dirInfo = new DirectoryInfo(rootPath.VolumeAndDirectory); FileInfo [] fileInfos = dirInfo.GetFiles(rootPath.FileAndExtension); files.AddRange(fileInfos); if (!rootPath.IsRootDirectory) { RecursiveGetParentFiles(rootPath.MakeParentPath().VolumeAndDirectory.Append(rootPath.FileAndExtension), ref files); } }