title: Search for all documents in a site that end with a specific extention using Sharepoint 2010 Client Object Model
body: <p>I'm absolutely new to Sharepoint programming, so I need a bit of guidance on how to get a list of all documents that exist within a Sharepoint site who's extension matches a value being passed in.</p>
  
  <hr>
  
  <p>Background:  As part of a merger, millions (7TB) of documents were imported into Sharepoint without regard to file type, simply so we could get that data stored from a system that was being shut down.  </p>
  
  <p>Included in these documents were dangerous file types like .exe, and .dll files, which we need to preserve but want to take proper steps to ensure malicious files of those types aren't directly down-loadable.  </p>
  
  <p>Our plan is to extract each file matching our search list, zip it, upload the zip and delete the original. To do this, we need a one shot application.</p>
  
  <p>There are actually multiple sites involved - so ideally I'd love to run one query to access all documents in all sites (they're all under one root but they each have their own databases) but I'm fine with iterating across a set of sites.</p>
  
  <hr>
  
  <p>My thinking is to use the Sharepoint Client Object Model to execute a query against each site to give me back a list of all files of a given type.  I want <em>something</em> like </p>
  
  <pre><code>SharepointSite site = new SharepointSite(siteElement, settings.RootURL);
  ClientContext clientContext = site.Context;
  ListCollection listCollection = clientContext.Web.Lists;
  clientContext.Load(listCollection, l=&gt;l.Name.EndsWith(".exe"));
  clientContext.Load(listCollection);
  clientContext.ExecuteQuery();
  </code></pre>
  
  <p>but that's definitely not it.</p>
  
  <p>How should I approach this issue?</p>