title: How to make a fast query to the file system?
body: <p>I'm trying to query the filesystem on a remote machine in order to get a list of file names in a specific directory.</p>
  
  <p>Until now, I'm using the DirectoryInfo class in .NET. Something like this:</p>
  
  <pre><code>DirectoryInfo dir = new DirectoryInfo("c:\dir");
  FileInfo[] files = dir.GetFiles("*.*");
  </code></pre>
  
  <p>But this query answers in an average of 20/30 seconds. Sometimes is lasts 50 seconds. That's to much. I want to optimize it. After some googling I've found that this could be done with WMI. But I'm not getting any success. I'm getting errors like "RPC server is unavailable" and I don't have access to change permissions or services in that machine.</p>
  
  <p>Does anyone have any other idea?</p>