One of the necessary evils of programming has been the need to write recursive routines in order to discover all the sub-folders and files on a file system based on a specified parent folder. Recursion is the practice of writing a routine that calls itself. In the case of "walking" a directory tree, a method can look at a folder, list all the files and folders in that folder, process each file, and then call itself for each of the folders. Recursion is not hard, it is just something that make you go "hmmmm" each time you do it.
My latest discovery is that I can now get all the subfolders of a parent folder with a single line of .Net code, returned as a string array. Then simply write a foreach loop that processes all files found in each of the fully-specified folders. No more recursion and it works like a charm. Can't stand the suspense? Here is the line of C# code that does it:
string folders = System.IO.Directory.GetDirectories(@"C:\My Sample Path\","*", System.IO.SearchOption.AllDirectories);
I would say that you can now forget recursion, but it is still a popular question in programming job interviews and certification tests, so you still need to get comfortable with it.
Hope that helps.
Okemos, MI USA