我在C#中使用System.Data.SQLite尝试为firefox写一个cookie,但是当我尝试打开一个连接时,我得到一个异常,说 "无法打开数据库文件",错误代码为14。
然而,如果我复制cookie.sqlite文件并将其移动到其他地方,我可以毫无问题地访问它,那么,是否有一些锁定机制,即使在firefox未打开时也是如此?
var strPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + @"\Mozilla\Profiles\qhy0pdxy.default-release\cookies.sqlite";
var strDb = "Data Source=" + strPath;
SQLiteConnection conn = new SQLiteConnection(strDb);
conn.Open();
绕过这个问题的一个方法是复制文件,执行插入,然后覆盖原始文件。不是最好的,但它的工作...