Is possible to get all directories, subdirectories and files with recursion.
I do this because i want to increase my programming logic, and learn how recursion work.
I know to do that with this way:
string path = "D://"; string rezdir,newpath; DirectoryInfo di = new DirectoryInfo(path); DirectoryInfo[] dir = di.GetDirectories().ToArray(); for (int i = 0; i < di.GetDirectories().Length; i++) { Console.WriteLine(dir[i].ToString()); } Console.WriteLine("\n\nChoose File: "); rezdir = Console.ReadLine(); newpath = path + rezdir; di = new DirectoryInfo(newpath); dir = di.GetDirectories().ToArray(); for (int i = 0; i < di.GetDirectories().Length; i++) { Console.WriteLine(dir[i].ToString()); } Console.ReadKey(); But i don't do that with recursion way, so ff someone can to do this, i'll be grateful to him.