title: File.CreateText - Access Denied
body: <p>I recently spent a while trying to figure out what permissions were needed to get this statement to work:</p>
  
  <pre><code>if (!File.Exists(path)) 
  {
      // Create a file to write to. 
      using (StreamWriter sw = File.CreateText(path)) 
      {
          sw.WriteLine("Hello");
          sw.WriteLine("And");
          sw.WriteLine("Welcome");
      }   
  }
  </code></pre>
  
  <p>I eventually have "Special Permissions" to "Everyone" which should have solved the problem.  Sadly it didn't, it may actually be a bug?</p>
  
  <p>The following works:</p>
  
  <pre><code>if (!File.Exists(_logFilePath))
  {
      using (var fs = File.Create(_logFilePath))
      {
          using (var sw = new StreamWriter(fs))
          {
               sw.WriteLine("Hello");
               sw.WriteLine("And");
               sw.WriteLine("Welcome");
          }
      }
  }
  </code></pre>
  
  <p>Theoretically identical (I think), but I couldn't get the first to work.</p>