title: Access to the path .... is denied
body: <p>I have created a .msi by using VS2008 setup project. My application frequently writes some value in a .txt file in the application directory (C:\Program Files\MyApp\MyFile.txt). After insalling it in Win7, it raises an exception "Access to the path .... is denied." </p>
  
  <p>But whenever I run it as administrator, no such exception occurs. Here is my <a href="http://sscce.org" rel="noreferrer">sscce</a></p>
  
  <pre><code>string FilePath=Application.StartupPath + @"\AppSettings\CurrentUserName.inf";
  using (StreamWriter writer=new StreamWriter(FilePath,false))
  {
      writer.Write(txtLoginName.Text.Trim());
  }
  MainForm.ProcessLogIn();
  this.DialogResult = DialogResult.OK;
  </code></pre>
  
  <p>I don't know how to solve this problem. Any suggestion?</p>