title: Is it possible to delete a file that is opened by a process under windows?
body: <p>For testing and simulation purposes I would like to delete a file that is currently open by my process.</p>
  
  <p>The <a href="http://msdn.microsoft.com/en-us/library/aa363858%28v=VS.85%29.aspx" rel="nofollow">CreateFile docs</a> state that it is possible to open a file in a mode (<code>FILE_SHARE_DELETE</code>) that allows the file the open handle is pointing to to be deleted by another operation. (And I already tried and confirmed this via CreateFile(FILE_SHARE_DELETE) + DeleteFile.)</p>
  
  <p>What I would like to know now however is, whether it is possible at all that a file that is opened by anyone without above mentioned flag to be deleted somehow?</p>
  
  <p>As far as I understand the <a href="http://msdn.microsoft.com/en-us/library/aa363915%28v=VS.85%29.aspx" rel="nofollow">DeleteFile docs</a> it would not be possible with this functions, as</p>
  
  <blockquote>
    <p>The DeleteFile function fails if an application attempts to delete a file that is open 
    for normal I/O or as a memory-mapped file.</p>
  </blockquote>
  
  <p>Is there any other way to delete a file that is open, but does not have the FILE_SHARE_DELETE flag set?</p>