即使连接已关闭,SQLite也会锁定文件

Chr*_*tiz 5 c# sqlite

以下陈述不应该是自动更新的吗?我在执行查询后尝试删除文件时出现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");
Run Code Online (Sandbox Code Playgroud)

joe*_*elc 6

我迟到了,但我不得不:

GC.WaitForPendingFinalizers();
GC.Collect();
Run Code Online (Sandbox Code Playgroud)

在调用File.Delete()之前.