public delegate void DirectoryHandler(DirectoryInfo info);
public void GetFolders(DirectoryInfo root, ref IList<DirectoryInfo> folders, DirectoryHandler currentDirectory)
{
foreach(DirectoryInfo dir in root.GetDirectories())
{
try
{
folders.Add(dir);
if(currentDirectory != null)
currentDirectory(dir);
this.GetFolders(dir, ref folders, currentDirectory);
}
catch(UnauthorizedAccessException)
{
Debug.WriteLine("No Access! ->{0}", dir.FullName);
}
}
}