Choose the newest file from each directory
<p>I am using this to choose a root folder and take the newest file from each directory before adding this files into my <code>listbox</code> but in some cases it does not choose the newest file. </p>

<pre><code>var rootDirFile = Directory
    .EnumerateFiles(pathToSearch, "*.doc", SearchOption.TopDirectoryOnly)
    .OrderByDescending(f =&gt; File.GetLastWriteTime(f))
    .Take(1);

var allNewestFilesOfEachFolder = Directory
    .EnumerateDirectories(pathToSearch, "*.*", SearchOption.AllDirectories)
    .Select(d =&gt; Directory.EnumerateFiles(d, "*.doc")
        .OrderByDescending(f =&gt; File.GetLastWriteTime(f))
        .FirstOrDefault());

foreach (string tempFile in rootDirFile.Concat(allNewestFilesOfEachFolder))
{
    //add the file
}
</code></pre>
