title: IIS site cannot access local client drive
body: <p>I am doing a project where the user is allowed to upload/download a file to SQL stream.</p>
  
  <p>This works perfectly when testing it locally but when i uploads it and have an IIS, it seems to not work.  I assumed it is a permission issue.</p>
  
  <p>I am unable to solve it.</p>
  
  <p>I even tried to use unprojected folders as shown below (with no luck):</p>
  
  <pre><code>string tempPath = System.IO.Path.GetTempPath();
  string tempPath2 = System.Environment.GetEnvironmentVariable("TEMP");
  string tempPath3 = Environment.GetFolderPath(System.Environment.SpecialFolder.ApplicationData);
  var fullpath = Path.Combine(tempPath2, "MeDoc.Doc");
  </code></pre>
  
  <p>I even tried using authentications as show below (also no luck):</p>
  
  <pre><code>DirectoryInfo di = new DirectoryInfo(fullpath);
  DirectorySecurity acl = di.GetAccessControl();
  AuthorizationRuleCollection rules = acl.GetAccessRules(true, true, typeof(NTAccount));
  WindowsIdentity currentUser = WindowsIdentity.GetCurrent();
  WindowsPrincipal principal = new WindowsPrincipal(currentUser);
  
  DirectorySecurity fsecurity = Directory.GetAccessControl("C:\\Temp\\Docs\\");
  SecurityIdentifier sid = new SecurityIdentifier(WellKnownSidType.AuthenticatedUserSid, null);
  FileSystemAccessRule writerule = new FileSystemAccessRule(sid, FileSystemRights.Write, AccessControlType.Allow);
  
  fsecurity.AddAccessRule(writerule);
  // Set the ACL back to the file
  Directory.SetAccessControl("C:\\Windows\\Temp\\", fsecurity);
  
  if (!string.IsNullOrEmpty("C:\\Temp\\Docs\\") &amp;&amp; Directory.Exists("C:\\Temp\\Docs\\"))
  {
      // Get your file's ACL
      DirectorySecurity fsecurity3 = Directory.GetAccessControl("C:\\Temp\\Docs\\");
  
      // Add the new rule to the ACL`enter code here`
      fsecurity3.AddAccessRule(writerule);
  
      // Set the ACL back to the file
      Directory.SetAccessControl("C:\\Temp\\Docs\\", fsecurity);
  }
  </code></pre>
  
  <p>Even in web.config:</p>
  
  <pre><code>&lt;authorization&gt;
  &lt;allow users="?"/&gt;
  &lt;!--&lt;anonymousAuthentication enabled="true" /&gt;--&gt;
  &lt;/authorization&gt;
  </code></pre>
  
  <p>the IIS service is using network account.</p>
  
  <p>Any help is appreciated.</p>
  
  <p>Please note almost all the methods I use work perfectly when debugging on my machine.</p>
  
  <p>It's a different story when it is on IIS on a web server running network account.</p>
  
  <p>In IIS it is using a pool that uses Network service (yes I also tried local system with no luck).  As for the site permission I allow read and write.</p>
  
  <p>If anyone can help or even better yet have a quick sample project, I would greatly appreciate it.</p>