title: Quickest way in C# to find a file in a directory with over 20,000 files
body: <p>I have a job that runs every night to pull xml files from a directory that has over 20,000 subfolders under the root.  Here is what the structure looks like:</p>
  
  <pre><code>rootFolder/someFolder/someSubFolder/xml/myFile.xml
  rootFolder/someFolder/someSubFolder1/xml/myFile1.xml
  rootFolder/someFolder/someSubFolderN/xml/myFile2.xml
  rootFolder/someFolder1
  rootFolder/someFolderN
  </code></pre>
  
  <p>So looking at the above, the structure is always the same - a root folder, then two subfolders, then an xml directory, and then the xml file.
  Only the name of the rootFolder and the xml directory are known to me.</p>
  
  <p>The code below traverses through all the directories and is extremely slow.  Any recommendations on how I can optimize the search especially if the directory structure is known?</p>
  
  <pre><code>string[] files = Directory.GetFiles(@"\\somenetworkpath\rootFolder", "*.xml", SearchOption.AllDirectories);
  </code></pre>