title: Access denied on Directory.CreateDirectory from ASP.Net application
body: <p>In my web application I have a button which creates a folder based on a date, as such:</p>
  
  <pre><code>if (!Directory.Exists(SaveLocation + DateTime.Now.Year + @"\" + DateTime.Now.Month + " - " + DateTime.Now.ToString("MMM") + @"\" + DateTime.Now.Day + @"\" ))
      Directory.CreateDirectory(SaveLocation + DateTime.Now.Year + @"\" + DateTime.Now.Month + " - " + DateTime.Now.ToString("MMM") + @"\" + DateTime.Now.Day + @"\");
  </code></pre>
  
  <p>When I run this code in localhost, this works fine. Whenever this runs on the server, I get the error:</p>
  
  <pre><code>Access to the path '\\server\share\savelocation\2014\06 - June\3\' is denied
  </code></pre>
  
  <p>Things I have tried:</p>
  
  <ul>
  <li>Site is run under Windows Authentication</li>
  <li>Given the folder and the share read/write permissions to Everyone</li>
  <li>Tried adding <code>&lt;identity impersonate="true" /&gt;</code> to the Web.config</li>
  <li>Changed Managed Pipeline mode of App Pool to Classic</li>
  </ul>
  
  <p>Why can the application not access this directory? </p>