I wrote a method that needed to find all files within a path, and I want to get all the files using recursion. Here's my current method:
public void doStart(DirectoryInfo dir, string filePattern) { try { foreach (FileInfo fileInfo in dir.GetFiles(filePattern)) { if (fileFound != null) { fileFound(fileInfo); } } } catch (Exception) { } try { foreach (DirectoryInfo dirInfo in dir.GetDirectories()) { doStart(dirInfo, filePattern); } } catch (Exception) { } } public void Start(string path, string filePattern) { doStart(new DirectoryInfo(path), filePattern); } Is there is better way to write this kind of recursion or is this good enough ?