mardi 14 juillet 2015

Delete sqlite database file in .net environment

I'm doing some integration tests of a software which uses SQLite.

The software needs to use a database file to prevent data being lost. After each of the tests, I want to delete the database file to leave everything as it was at the beginning.

The problem is that when I Try to delete the file It throws an exception which says "System.IO.IOException: The process cannot access the file '*****' because it is being used by another process". Before trying to delete the file, I'm closing and disposing of the connection like this:

if(_connection.State == System.Data.ConnectionState.Open) _connection.Close();
_connection.Dispose();

To delete the file I am using the instruction: File.Delete(_databaseFilePath); What am I doing wrong?, Do I miss something? Thanks in advance.

Aucun commentaire:

Enregistrer un commentaire