title: How to use Directory.GetFiles to get only gif types (or any other type)?
body: <p>I'm trying to filter files by extension (in particular case ".gif") but <code>GetFiles</code> method for some reason does not find any files (even if there are definitely files of that type in the folder).</p>
  
  <p>This code gives me list of all files.</p>
  
  <pre><code>private void displaylastanimatedgif()
          {
              var directory = new DirectoryInfo(animatedgifsdirectory);
              var myFile = (from f in directory.GetFiles()
                            orderby f.LastWriteTime descending
                            select f).First();
              if (myFile != null)
                  pictureBoxImage(myFile.FullName);
              listBox1.Items.Add(outputfile);
          }
  </code></pre>
  
  <p>If I add filter to the <code>GetFiles()</code> like <code>Directory.GetFiles("*.gif")</code> I will get exception:</p>
  
  <blockquote>
    <p>Sequence contains no elements.</p>
  </blockquote>