views:

148

answers:

2

Lets assume the following function:

private void ParseFolder(string strFolder)
{
    foreach (string currentFolder in Directory.GetDirectories(strFolder))
    ParseFolder(strFolder);
}

Now we start our recursive loop with:

ParseFolder("C:\");

Is there a way to be notified when this recusrive loop ends (= all directories have been parsed)?

+2  A: 

Yes, just add a method call after it:

ParseFolder("C:\\"); // You need to escape \
Notify();
Mehrdad Afshari
Haha. I found that funny for some reason.
Charlie Somerville
+1  A: 
private void DoWork()
{
     ParseFolder("C:\\");
     // Once you get here, the work is done.
}


private void ParseFolder(string strFolder)
{
    foreach (string currentFolder in Directory.GetDirectories(strFolder))
    ParseFolder(strFolder);
}
Cory Larson