title: Delete sqlite db file
body: <p>I am developing a C# application with its backend as sqlite. In my application I have a button for cleaning the database (deleting the .db file and creating it again with some initial data). Sometimes when I try to delete the db it says it cannot be deleted because it is being used by another process. Before deleting it I am using close connection, dispose and clear pool functions. Even then it throws the same exception. Here is my code:</p>
  
  <pre><code>string targetDataBaseFilePath = Path.Combine(dataDirectoryPath, "local.db");               
  ThingzDatabase.Create(targetDataBaseFilePath, "touchdb");
  </code></pre>
  
  <p>In the create function I define the following code, from where I get the error:</p>
  
  <pre><code>if (File.Exists(DatabaseFileName))
  {
      try
      {
          ThingzDatabase.localdb.conn.Close();
          ThingzDatabase.localdb.conn.Dispose();
          SQLiteConnection.ClearAllPools();
      }
      catch (Exception)
      {
      }
      File.Delete(DatabaseFileName); //error throws from here.                       
  }
  </code></pre>
  
  <p>How can I prevent the error from being thrown?</p>