title: What is the fastest way to get lists of files and search through file lists repeatedly?
body: <p>What is the fastest way to get lists of files and search through file lists repeatedly?</p>
  
  <p>Situation:</p>
  
  <ol>
  <li>There can be 5,000 to 35,000 files spread over 3-5 root directories (that have many subdirectories) on a network drive.</li>
  <li>There are three file types (tif, sus, img) that a user may or may not search for.  Some file types can have 2-3 different file extensions.</li>
  <li>From a list of files (in various database tables), I need to find out if each file exists, and if it does, save the path only and filename only to a table.</li>
  <li>Searches on file names must be case sensitive but it would be nice to keep original case when saving the path to the table.</li>
  </ol>
  
  <p>Environment:</p>
  
  <p>C# and .NET 4.0 on Windows PC.</p>
  
  <p>Is this the fastest way?:</p>
  
  <p>Is the fastest way to use a dictionary, with FileName as a key (lowercase) and Path as a value (original case)?
  In this way I can get the index/Path at the same pass when I search for the filename?  The FileName and Path are split up front when populating the list.</p>
  
  <pre><code>if (d.TryGetValue("key", out value))
  {
      // Log "key" and value to table  // only does one lookup
  }
  </code></pre>
  
  <p>Note: I am a bit concerned that I probably will have duplicate key values per FileType.
  When/If I run across this scenario what type of list and access method should I use?</p>
  
  <p>Maybe on these rare cases, I should populate another list of the duplicate keys.  Because I will need to do at least one of: log/copy/delete of the files in any path.</p>