title: How do I configure my ASP.NET directory to allow writing a log file?
body: <p>Ok so I believe I am doing something very easy here. I have written an ASP.NET web page and it is just trying to write to the local directory. </p>
  
  <p>I am using the following code:</p>
  
  <pre><code>System.IO.File.WriteAllLines("log.txt", messages);
  </code></pre>
  
  <p>I am throwing the following exception. </p>
  
  <pre><code>Access to the path 'c:\windows\system32\inetsrv\log.txt' is denied.
  </code></pre>
  
  <p>My ASP.NET application sits in the following directory.</p>
  
  <pre><code>c:\inetpub\wwwroot\sites\mysite\
  </code></pre>
  
  <p>So I am confused as to why it is trying to write to c:\windows\system32\inetsrv\ directory when I am not supplying that directory itself. </p>
  
  <p>I have tried changing the code to the following but it gives me the same error message with a new directory.</p>
  
  <pre><code>System.IO.File.WriteAllLines("c:\\inetpub\\wwwroot\\sites\mysite\log.txt", messages);
  </code></pre>
  
  <p><strong>Edit 1</strong></p>
  
  <p>It was hard to accept an answer on this because everyone really helped me out a ton. I accepted tom_yes_tom's answer because he was the first to post his response which was the first half of my problem. The other half of my problem was related to hbrock's solution that Fabio pointed out.</p>