title: c# Can't Append text to existing file
body: <p>I am trying to append some text to an existing TEXT file using c#.  I have tried the four different ways below and it isn't working.  This does work on my machine at home, but not on my desktop here at work (so I'm assuming it's something different between the two PCs and not the c# code.)  I've looked at the permissions on this text file and everything seems fine.  I certainly have the correct rights to write to this file.  They are both runnings Windows 10.  Both machines are running Visual Studio 2019 Community Edition version 16.11.3.  I'm an Administrator on both machines.</p>
  <pre><code>var thePath = &quot;C:\\Temp\\Logs\\MyTextFile.txt&quot;;
  
  File.AppendAllText(thePath, &quot;New Data&quot; + Environment.NewLine);
  
  File.AppendAllLines(thePath, new [] { &quot;New Data&quot; });
  
  using (StreamWriter sw = new StreamWriter(thePath, true))
  {
      sw.WriteLine(&quot;New Data&quot;);
      sw.Flush();
      sw.Close();
  }
  
  using (StreamWriter sw2 = File.AppendText(thePath))
  {
      sw2.WriteLine(&quot;New Data&quot;);
      sw2.Flush();
      sw2.Close();
  }
  </code></pre>
  <p><a href="https://i.stack.imgur.com/UUreE.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/UUreE.png" alt="enter image description here" /></a></p>
  <p><a href="https://i.stack.imgur.com/WPJWE.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/WPJWE.png" alt="enter image description here" /></a></p>