title: Detect and handle application sudden endtask ,restart and shutdown?
body: <p>I have an application that stores an XML Encrypted Document, each time the application wants to access the XML file it have to (decrypt-->read-->write-->encrypt). if a sudden shutdown or restart even a end task from task manager will result on either corrupted data in the XML or a un-encrypted XML file, so in the next run it will produce an error.</p>
  
  <p>What i though about is to store the whole content of the XML in a the database and check if there are any errors then replace the old content.</p>
  
  <p>Any ideas, tips, or thoughts much appreciated.</p>