title: ASP.NET Logon Failure IOException with Response.WriteFile but not with File.Copy?
body: <p>I'm attempting to send a file to the browser that is located on a remote host (via UNC). </p>
  
  <p>The web app is running both under impersonation and an App Pool with a user that has full access to the remote host's UNC directory (via matching credentials). </p>
  
  <p>I can read and write files with no issues on the UNC path using the System.IO object's File.Copy. However, when I attempt </p>
  
  <pre><code>  Dim file As System.IO.FileInfo = New System.IO.FileInfo([UNCFilePath])
    Response.Clear()
    Response.AddHeader("Content-Disposition", "attachment; filename=" &amp; file.Name.Replace(" ", "_"))
    Response.AddHeader("Content-Length", file.Length.ToString())
    Response.ContentType = "application/octet-stream"
    Response.WriteFile(file.FullName)
  </code></pre>
  
  <p>I get </p>
  
  <pre><code>System.IO.IOException: Logon failure: unknown user name or bad password
  </code></pre>
  
  <p>If I copy the file via File.CopyTo to a local directory and do a writefile from there, it works. </p>
  
  <p>My main question, outside of solution to this problem, is why does File.Copy work and File.Response not work? Aren't they both using System.IO? </p>