Is Directory.EnumeratedDirectorties postponed before execution?
<p>I am using the following code </p>

<p><code>var allFolderPaths = Directory.EnumerateDirectories(this.sourceFolder, "*.*", SearchOption.AllDirectories);</code> </p>

<p>The issue I am having , is during a foreach loop (iterating over the allFolderPaths variable as shown above), it is failing because the directory is not found.</p>

<p>Now, the following code is, by itself not looking at directories etc, it's just a string loop:</p>

<pre><code>foreach (string folder in StringList)
{
       /dostuff 
}
</code></pre>

<p>However, when I update the code to use the allFolderPaths (As per the first example in this post)</p>

<pre><code>foreach (string folder in allFolderPaths)
{
       /dostuff 
}
</code></pre>

<p>it fails due to "access to a path denied"! </p>

<p>So, does this mean the variable allFolderPaths is not actually 'assigned' at the point it is assigned to (if that makes any sense)?</p>
