title: ASP.NET cannot read file: "access to the path ... is denied"
body: <p><strong>tl;dr: critical bits are in bold.</strong></p>
  
  <p>We have a website page that, when executed, is supposed to read in a series of files, zip them up, and return them to the user.</p>
  
  <p>Unfortunately, we are running into an error:</p>
  
  <blockquote>
    <p>ASP.NET is not authorized to access the requested resource. Consider
    granting access rights to the resource to the ASP.NET request
    identity. ASP.NET has a base process identity (typically
    {MACHINE}\ASPNET on IIS 5 or Network Service on IIS 6) that is used if
    the application is not impersonating. If the application is
    impersonating via , the identity will be
    the anonymous user (typically IUSR_MACHINENAME) or the authenticated
    request user.</p>
  </blockquote>
  
  <p>My line attempting to access the file currently looks like this:</p>
  
  <pre><code>using (FileStream x = File.Open(@"\\thedirectory\filename.pdf", FileMode.Open, FileAccess.Read)) { }
  </code></pre>
  
  <p>(This line doesn't do anything useful other than try to open the file, since right now I'm just trying to see if I have access at all.)</p>
  
  <p><strong>This code works, and opens the file without a problem if I copy the file to a directory on my machine and have the path go there.  But if I go to the remote machine where the original file is, no dice.</strong></p>
  
  <p>I went down a rabbit hole for a while trying to make sure that whoever the ASP.NET process was running as, that process had permissions to the directory.  However, since that wasn't working and I was getting desperate, <strong>I have given "everyone" all access rights to the remote directory as a test.  Still getting the same error.</strong></p>
  
  <p>I'm guessing this is a permissions issue (since that's what it's claiming) combined with the fact that the code works when pointing at a local file.  However, <strong>since I've already given "everyone" all permissions, I'm lost as to what could be going wrong.</strong>  </p>
  
  <p>Ideas?</p>