title: one file 2 different application one to read one to write
body: <p>Is it possible to create 2 applications that one always writes to file (like a log file) and other application that can read from a file?</p>
  
  <p>I'd show you what I've tried:</p>
  
  <p><strong>Writter application</strong></p>
  
  <pre><code>static void Main(string[] args)
      {
          string file = @"D:\filetest.txt";
          int i = 0;
          while (true)
          {
  
              using(FileStream fs = File.OpenWrite(file))
              {
                  using(StreamWriter sw = new StreamWriter(fs))
                  {
                      sw.WriteLine($"line line {i++}");
                  }
              }
              Thread.Sleep(500);
          }
      }
  </code></pre>
  
  <p><strong>reader application</strong></p>
  
  <pre><code>    static void Main(string[] args)
      {
          string file = @"D:\filetest.txt";
          int i = 0;
          while (true)
          {
              string lines = string.Empty;
              using (FileStream fs = File.OpenRead(file))
              {
                  using (StreamReader sw = new StreamReader(fs))
                  {
                       lines = sw.ReadToEnd();
                  }
              }
              Console.WriteLine(lines);
              Thread.Sleep(200);
          }
      }
  </code></pre>
  
  <p>Of course as I expected I got exception on <code>File.OpenWrite(file)</code> line 
  <code>"he process cannot access the file 'D:\filetest.txt' because it is being used by another process."</code></p>
  
  <p>The only solution I think is to copy the written file before reading it.</p>