title: File Read/Write Locks
body: <p>I have an application where I open a log file for writing. At some point in time (while the application is running), I opened the file with Excel 2003, which said the file should be opened as read-only. That's OK with me.</p>
  
  <p>But then my application threw this exception:</p>
  
  <blockquote>
    <p>System.IO.IOException: The process cannot access the file because another process has locked a portion of the file.</p>
  </blockquote>
  
  <p>I don't understand how Excel could lock the file (to which <em>my app</em> has write access), and cause my application to fail to write to it!</p>
  
  <p>Why did this happen?</p>
  
  <p>(Note: I didn't observe this behavior with Excel 2007.)</p>