Hezký den, zkuste to rekurzivním procházením. Doufám, že nevadí C# :
static void Main(string[] args)
{
var directory = new DirectoryInfo(@"c:\install");
var directories = GetSubdirectories(directory);
var directoriesString = string.Join(",", directories.Select(d => d.Name));
Console.WriteLine(directoriesString);
}
private static List<DirectoryInfo> GetSubdirectories(DirectoryInfo directory)
{
var directories = new List<DirectoryInfo>();
FillSubdirectoriesRecursive(directory, directories);
return directories;
}
private static void FillSubdirectoriesRecursive(DirectoryInfo currentDirectory, List<DirectoryInfo> directories)
{
foreach (var subdirectory in currentDirectory.GetDirectories())
{
directories.Add(subdirectory);
FillSubdirectoriesRecursive(subdirectory, directories);
}
}
R.
|