title: C# can not write to file ("being used by another process")?
body: <p>I was hoping someone could explain to me why this is happening :)</p>
  
  <p>When I use the code below it gives me the error "The process cannot access the file 'C:\test.txt' because it is being used by another process."</p>
  
  <p>I'm very new to C# so I'm not sure what is going on, thanks in advance!</p>
  
  <pre><code>String fileNameBefore = @"C:\\test.txt";
  
  public void output(String hex)
  {
      using (StreamWriter writer = new StreamWriter(fileNameBefore, true))
      {
          writer.Write(hex);
          writer.Close();
      }
  }
  </code></pre>