title: Access to a Sharepoint Remote Folder from C#
body: <p>I have developed an ASP.NET MVC 3 which must access to a SharePoint Remote Folder.</p>
  
  <p>To do that, during the development, before to run the Visual Studio Development Server, I try to access to the remote folder. Then, I must introduce the credentials of the user who has permission to see the remote resource. After this, using the following code:</p>
  
  <pre><code>string path = @"\\tests.sharepoint.es\folder1";
  DirectoryInfo di = new DirectoryInfo(path);
  DirectoryInfo[] dis = di.GetDirectories();
  </code></pre>
  
  <p>The access to the folder is successful. However, this fails when I executed my web application from the IIS, getting the next error:</p>
  
  <p><i>Access to the path '\tests.sharepoint.es\folder1\' is denied.</i></p>
  
  <p>Even if I set for the Application Pool the same user that runs the Visual Studio Development Server, it continues failing.</p>
  
  <p>I have identified that the users who runs the World Wide Web Publish Service (W3SVC) is SYSTEM (an account who obviously doesn't have permission to access to the folder) but I can't change this and I am not sure if this causes the problem.</p>
  
  <p>Also, I have read some posts about using <i>SPSecurity.RunWithElevatedPrivileges</i> but I can't use it because my IIS server doesn't have Sharepoint installed (it is in another machine) and therefore, I can't use Microsoft.Sharepoint.dll as far as I know.</p>
  
  <p><strong>UPDATE:</strong> When I try to access to the resource using my windows explorer, I have read that OS uses WebDav instead of NetBios. Can IIS use this protocol to access to the resource?</p>