title: How to append to a file after File.CreateText?
body: <p>I am writing a C# app that needs to create a CSV file.</p>
  
  <p>The problem is after issuing a File.CreateText({file path}), I cannot immediately write to it. If the file already exists, I can write no problem. Here is the code:</p>
  
  <pre><code>if (!File.Exists(file_name))
          {
  
              File.CreateText(file_name);
              File.WriteAllText(file_name, String.Format("Old Name,Short Name{0}", this.old_name_txt.Text, this.new_name_txt.Text, Environment.NewLine));
          }
          else
          {
              File.AppendAllText(file_name, String.Format("{0},{1}{2}", this.old_name_txt.Text, this.new_name_txt.Text, Environment.NewLine));
          }
  </code></pre>
  
  <p>After creating the file, I have also tried "File.AppendAllText..."</p>
  
  <p>The error it is producing says that it cannot write because the file is being used by another process.</p>