You'll need microsoft transaction server (mts) for this. With it, you create a transaction context, execute multiple actions (like file handling and database updates, also mixed) that all need to call SetComplete (indicating the code didn't encounter any problems). When you then call Commit, MTS will try to commit all the actions. If one of the actions called SetAbort or the Commit somehow fails, a full rollback will ensure nothing changed.
Check out this link for more info: