static void ProcessDirectory(DirectoryInfo root) { FileInfo[] files = null; DirectoryInfo[] subDirs = null; try { files = root.GetFiles("*"); } catch (UnauthorizedAccessException e) { ScreenRenderer.WriteError("Unauthorized: Unable to access template files", e.Message); } catch (DirectoryNotFoundException e) { ScreenRenderer.WriteError("Directory Not Found: Unable to access template files", e.Message); } catch (Exception e) { ScreenRenderer.WriteError("Unknown Error: Unable to access template files", e.Message); } if (files != null) { foreach (FileInfo sourceFile in files) { SourceFileData sourceFileData = new SourceFileData(); sourceFileData.FileName = sourceFile.Name; sourceFileData.FilePath = sourceFile.FullName; sourceFileData.Size = sourceFile.Length; sourceFileData.DirectoryPath = root.FullName; sourceFileData.FileId = Guid.NewGuid(); sourceFileData.ByteCounts = FileChecker.TestByteCount(MaxByteCode, sourceFile.FullName); SourceFiles.Add(sourceFileData); } } subDirs = root.GetDirectories(); if (subDirs != null) { foreach (DirectoryInfo dirInfo in subDirs) { ProcessDirectory(dirInfo); } } }