I'm having some trouble generating an output in my last for loop. I'm suposed to be generating a list of folders that fit the criteria in the double for loop but black screen is just stuck doesnt even display the press any key to exit messsage. Help would be much appreciated
namespace ArchivingApplication
{
class Program
{
static void Main()
{
//regex pattern to get folder names of the type #.#.#.#/#. something
Regex reg = new Regex(@"\d+(\.\d+)+");
//setting where to start looking
DirectoryInfo root = new DirectoryInfo(@"\\Visrep01\references");
DirectoryInfo[] parent = root.GetDirectories();
DirectoryInfo[] subDirectories = null;
List<DirectoryInfo> candidates = new List<DirectoryInfo>();
try
{
foreach (DirectoryInfo directory in parent)
{
subDirectories = directory.GetDirectories();
Console.WriteLine(directory);
foreach (DirectoryInfo subdirectory in subDirectories)
{
//Console.WriteLine(subdirectory);
candidates.AddRange(subdirectory.GetDirectories("*",SearchOption.AllDirectories).Where(d => reg.IsMatch(d.Name)).Where(d => !d.FullName.EndsWith("TESTS")).Where(d => !(d.GetDirectories().Length == 0 && d.GetFiles().Length == 0)).ToList());
}
}
}
catch (Exception e) { }
foreach(DirectoryInfo dir in candidates)
{
Console.WriteLine(dir.FullName);
}
//keep the application in debug mode
Console.WriteLine("Press any key to exit.");
Console.ReadKey();
}
} }