title: ASP.NET application gets system.unauthorizedaccessexception when accessing a network drive
body: <p>I'm attempting to access a network drive from an ASP.NET page. Technically it's a SharePoint application page (_layouts/mycompany/mypage.aspx) but I believe the principles are the same.</p>
  
  <pre><code>string filePath = @"\\companyshare\temp\test.txt";
  FileStream fs = new FileStream(filePath, FileMode.Open, FileAccess.Read);
  </code></pre>
  
  <p>When I hit the second line in the code above I get the error:</p>
  
  <blockquote>
    <p>Access to the path '\companyshare\temp\test.txt' is denied.</p>
  </blockquote>
  
  <p>The application pool for this site is running under a domain account (MYCOMPANY\adminacct). MYCOMPANY\adminacct has access to the file \companyshare\temp\test.txt. I've confirmed that by logging into the server with the MYCOMPANY\adminacct credentials and navigating to the file using the same path that is in the code.</p>
  
  <p>I'm running IIS 7.5</p>
  
  <p><strong>Questions</strong></p>
  
  <p>How come the above code is still getting access denied even though the application pool account has access to the folder and file?</p>
  
  <p>Is there a way to confirm that my code is actually trying to access that file with the credentials I believe it is using?</p>