title: Write a log file
body: <p>I have a recent problem . I can upload file in my intetpub/wwwrooot/folder</p>
  
  <p>But I can't write a log file in this same folder ... </p>
  
  <p>I have all the permissions for the network service. Everything is on my server.</p>
  
  <pre><code>DirectoryInfo di = new DirectoryInfo(~/);
  
  // Get a reference to each file in that directory.
  FileInfo[] fiArr = di.GetFiles();
  
  
  string strLogText = di;
  
  // Create a writer and open the file:
  StreamWriter log;
  
  if (!System.IO.File.Exists("C:\\inetpub\\wwwroot\\logfile.txt"))
  {
      log = new StreamWriter("C:\\inetpub\\wwwroot\\logfile.txt");
  }
  else
  {
      log = System.IO.File.AppendText("C:\\inetpub\\wwwroot\\logfile.txt");
  }
  
  // Write to the file:
  log.WriteLine(DateTime.Now);
  log.WriteLine(strLogText);
  log.WriteLine();
  
  // Close the stream:
  log.Close();
  </code></pre>
  
  <p>The error is the access is denied ! </p>
  
  <p>It works locally , but on my server it doesnt. On the folder Inetpub , I just need to allow writting for Network service ? That is strange because I can upload file and writting is already enable </p>