title: How to "transaction" a IO operation and a database execution?
body: <p>I have service that contains a processor running, and it do two things:</p>
  
  <pre><code>1- Create a file in a directory.
  2- Set your own status to "Processed".
  </code></pre>
  
  <p>But, when the service is stopped exactly in the middle of processing, the file is created in the directory but, the process is not finalized, like this:</p>
  
  <pre><code>  1- Create a file in a directory.
     -----SERVICE STOPPED-----
    2- Set your own status to "Processed".
  </code></pre>
  
  <p>I need a way to transact the IO operations with the database commands, how to do this?</p>
  
  <p><strong>EDIT - IMPORTANT</strong></p>
  
  <p>The problem is that the file created is captured by another application, so the file needs to be really created only if the commands are executed successfully. Because if the file be created and the another application capture him, and after an database error occurs, the problem to be continued.</p>
  
  <p>OBS: I'm using c# to develop.</p>