title: Getting around file access protection in Windows to view an active logfile read-only
body: <p>A customer asked for quick and dirty log viewer for an ASP.NET app, for which I'm using log4net, and I thought somehow we could simply add a controller to read the tail of the active file and spit it back.</p>
  
  <p>If I use the standard .NET API (File.OpenText, etc.) I get access violation (file open by another process), which is what I expect, but I know it is possible to read the file because Ultraedit opens it for viewing read-only. Can I do the same from the .NET API?</p>
  
  <pre><code>using(StreamReader infile =
           System.IO.File.OpenText(Request.PhysicalApplicationPath + @"\log\my.log"))
  {
  }
  </code></pre>