title: Access to the path 'xxx' is denied (where 'xxx' is a folder)
body: <p>I know this has been asked before many times, but I have browsed tens of similar questions without help. </p>
  
  <p>This error is showed when my asp.net 4.0 application tries to access a folder on my local drive, doing this:</p>
  
  <pre><code>XmlTextReader confReader = new XmlTextReader (filename);           
  while (confReader.Read())  // &lt;- error line
  {
    // do something
  }
  </code></pre>
  
  <p>In my web.config I have &lt;Identity Impersonate="true"&gt;. For the folder I have assigned full-access to:</p>
  
  <pre><code>everyone 
  IIS APPPOOL\&lt;custom apppoolname&gt; 
  NETWORK SERVICE
  </code></pre>
  
  <p>Debugging the application, I can put up a watch which evaluates this call right before the incriminated line:</p>
  
  <pre><code>System.Security.Principal.WindowsIdentity.GetCurrent().Name.ToString();
  </code></pre>
  
  <p>the call shows the current user is IIS APPPOOL\&lt;custom apppoolname&gt;.</p>
  
  <p>I'm on Windows 7 64bit with Sp1. I know it's probably something stupid but I have already spent an awful amount of time on this.</p>
  
  <p><strong>Edit</strong>:<br>
  The problem was in the variable "filename", which pointed to the right folder, but for a configuration problem the filename was missing (i.e. the content was "c:\data\" instead of "c:\data\file.xml"). The Asp.net error was actually confusing, since I had all the right permissions to access that folder. DJKRAZE pointed me to the right direction.</p>