title: How to bring coordination between file system and database?
body: <p>I am working on a online file management project. We are storing references on the database (sql server) and files data on the on file system. </p>
  
  <p>We are facing a problem of coordination between file system and database while we are uploading a file and also in case of deleting a file. First we create a reference in the database or store files on file system. </p>
  
  <p>The problem is that if I create a reference in the database first and then store a file on file system, but while storing files on the file system any type of error occur, then the reference for that file is created in the database but no file data exist on the file system.</p>
  
  <p>Please give me some solution how to deal with such situation. I am badly in need of it.</p>
  
  <p>This case happens also while we deleting a file?</p>