title: Writing text to file from multiple instances of program
body: <p>When I write info to file and multiple copies of program are runnnig I get this error:</p>
  
  <blockquote>
    <p>The process cannot access the file 'C:\logs\log.txt' because it is being used by another process.</p>
  </blockquote>
  
  <p>code is:</p>
  
  <pre><code>// create a writer and open the file
  TextWriter tw2 = File.AppendText(@"C:\logs\log.txt");
  
  // write a line of text to the file
  tw2.WriteLine(Environment.NewLine);
  tw2.WriteLine(DateTime.Now + " " + "IN INFOSERVCALLER");
  tw2.Flush();
  </code></pre>
  
  <p>How to do it in right way?</p>