title: Read log file being used by another process
body: <p><strong>Goal</strong></p>
  
  <p>I want to press a button on my GUI and read in the seclog.log file (symantec AV log) from a remote machine and display the contents of the log to a rich text box in my application. </p>
  
  <p><strong>Things That Work</strong></p>
  
  <p>everything but reading the log file</p>
  
  <p><strong>Error Message</strong></p>
  
  <pre><code>System.IO.IOException was unhandled
  Message=The process cannot access the file '\\HOSTNAME\C$\Program Files (x86)\Symantec\Symantec Endpoint Protection\seclog.log' because it is being used by another process.
  Source=mscorlib
  </code></pre>
  
  <p><strong>code</strong></p>
  
  <pre><code>//possible seclog paths
          String seclogPath1 = @"\\\\" + target + "\\C$\\Program Files (x86)\\Symantec\\Symantec Endpoint Protection\\seclog.log";
          String seclogPath2 = @"\\\\" + target + "\\C$\\Program Files\\Symantec\\Symantec Endpoint Protection\\seclog.log";
  
          //if seclog exists
          if (File.Exists(seclogPath1))
          {
              //output.AppendText("file exists at " + seclogPath1);
              //var seclogContent = File.Open(seclogPath1, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
  
              Stream stream = File.OpenRead(seclogPath1);
              StreamReader streamReader = new StreamReader(stream);
              string str = streamReader.ReadToEnd();
              output.AppendText(str);
              streamReader.Close();
              stream.Close();
  
  
          }
  </code></pre>
  
  <p><strong>Things I've Tried</strong></p>
  
  <p><a href="https://stackoverflow.com/questions/3737444/file-is-being-used-by-another-process">File is being used by another process</a></p>
  
  <p><a href="https://stackoverflow.com/questions/3803929/c-sharp-the-process-cannot-access-the-file-because-it-is-being-used-by-anoth">C# The process cannot access the file &#39;&#39;&#39; because it is being used by another process</a></p>
  
  <p>Googling the issue</p>
  
  <p>using filestreams in multiple ways</p>