title: StreamWriter Access Denied on Windows Startup
body: <p>I'm having an issue with StreamWriter, here's my code:</p>
  
  <pre><code>WebClient versionDownloader = new WebClient();
  versionDownloader.DownloadFile("/* Version file here */", "EHWVBVersion.txt");
  StreamReader reader = new StreamReader("EHWVBVersion.txt");
  if (Version.Parse(reader.ReadLine()) &gt; version)
  {
      DialogResult dialogResult = MessageBox.Show("New version available ! Do you want to download it ?", "EHWVB", MessageBoxButtons.YesNo);
      if (dialogResult == DialogResult.Yes)
      {
          reader.Close();
          File.Delete("EHWVBVersion.txt");
          Process.Start("/* Download link Here */");
          Application.Exit();
      }
  }
  reader.Close();
  File.Delete("EHWVBVersion.txt");
  </code></pre>
  
  <p>(Yes, there are actual links instead of comments in my code)</p>
  
  <p>It's giving me an error mentioning Access Denied to "C:\WINDOWS\System32\EHWVBVersion.txt" even though I'm not wrtiting there. I guessed it had to so with something about temp file not loaded yet so I tried to print mentioned path before and tried, and nope, it is loaded.
  So then I coded this function :</p>
  
  <pre><code>private void Log(string line)
  {
      if (!File.Exists("EHWVB.log"))
          File.Create("EHWVB.log").Close();
      StreamWriter writer = new StreamWriter("EHWVB.log", true);
      writer.WriteLine(DateTime.Now + " : " + line);
      writer.Close();
  }
  </code></pre>
  
  <p>And tried to log everything that was accessing the version file.
  I was quite surprise to discover that it isn't my version file that creates an issue or it's path, but the File Creation process directly. Same error, but for "C:\WINDOWS\System32\EHWVB.log" this time.</p>
  
  <p>The thing is, if I try all this again not on Windows Startup, everything work fine. Version file is downloaded, logging works, etc.</p>
  
  <p>Any idea ?</p>