title: How to delete a file which is locked?
body: <p>I am writing a desktop application under Windows in C++ MFC.</p>
  
  <p>The application creates a index file, and writes information to it again and again.</p>
  
  <p>If the application crashes, the next time the application starts it will delete the crashed index file and create a new one. I think in certain cases, the index file will be locked. It will be a disaster if I can not delete the locked index file.</p>
  
  <p>How can I guarantee that I can delete the file and create a new one? I can make sure no other application opens the index file. It cannot be deleted just because of an application crash.</p>
  
  <p>Can any one help?</p>