下面的语句不应该自动提交吗?我在执行查询后收到一个试图删除文件的 IOException。
using (SQLiteConnection connection = new SQLiteConnection("Data Source=" + AppDomain.CurrentDomain.BaseDirectory + "data\\test.db;Version=3;"))
{
connection.Open();
SQLiteCommand command = new SQLiteCommand("CREATE TABLE IF NOT EXISTS test (id INTEGER)", connection);
command.ExecuteNonQuery();
}
//throwing an IOException
File.Delete(AppDomain.CurrentDomain.BaseDirectory + "data\\test.db");
最佳答案
我迟到了,但我不得不:
GC.WaitForPendingFinalizers();
GC.Collect();
在调用 File.Delete() 之前。
关于c# - SQLite 锁定文件,即使连接已关闭,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2779599/