title: How do I search through directories recursively?
body: <p>I need to change a lot of file names all in the same way. They all share a common root but are scattered through out that root in other folders. I am trying to write a program in c# that starts at the root and recursively goes through all of its children and either changes file names or goes into the next folder.  Here is what I have:</p>
  
  <pre><code>public void cascade(string path)
      {
          if(IsDirectoryEmpty(path) == true) 
          { }
          else
          {
              String[] childFolders = Directory.GetDirectories(path);
              String[] childFiles = Directory.GetFiles(path);
              ChangeFileName();
  
              for (int p = 0; p &lt; childFolders.Length; p++)
              {
                  cascade(childFolders[p]);
              }
          }
      }
  </code></pre>
  
  <p>A button calls to cascade and passes in the initial root directory. I then found someones method they wrote to check if its empty:</p>
  
  <pre><code>public bool IsDirectoryEmpty(string path)
      {
          return !Directory.EnumerateFileSystemEntries(path).Any();
      }
  </code></pre>
  
  <p>Im trying to change the fileNames everytime I enter a new directory and if there are more folders I enter them to change more file names. It isnt working and I have no clue why. Changing the file names works but this method isnt reaching all of the folders.</p>