小编Bor*_*ris的帖子

无法使用System.Data.Sqlite访问Sqlite数据库(Firefox)

我写了一个小的C#/ .Net应用程序,它能够读取Firefox的cookies.sqlite文件.自从我升级到Firefox 4后,我的应用程序无法打开数据库文件:

执行"connection.Open();"行 (在下面的代码示例中)会有一个execption说:

"文件已打开,不是数据库文件.文件已加密或不是数据库"

这是我的程序代码:

class Program
{
    static void Main()
    {

        const string PATH_TO_DATABASE = @"C:\Users\Boris\Desktop\TEMP\cookies.sqlite";
        const string CONNECTION_STRING = @"Data Source=" + PATH_TO_DATABASE;

        if (!File.Exists(PATH_TO_DATABASE)) return;

        using (SQLiteConnection connection = new SQLiteConnection(CONNECTION_STRING))
        {
            connection.Open();
            using (SQLiteCommand command = new SQLiteCommand("SELECT id, name, host, path FROM moz_cookies", connection))
            {
                using (SQLiteDataReader read = command.ExecuteReader())
                {
                    while (read.Read())
                    {
                        string id = read[0].ToString();
                        string name = read[1].ToString();
                        string host = read[2].ToString();
                        string path = read[3].ToString();
                        Console.WriteLine("ID: " + …
Run Code Online (Sandbox Code Playgroud)

.net c# firefox system.data.sqlite

1
推荐指数
1
解决办法
4979
查看次数

标签 统计

.net ×1

c# ×1

firefox ×1

system.data.sqlite ×1