如何使用C#应用程序获取Firefox历史记录?

时间:2012-12-04 12:20:14

标签: c#-4.0 firefox windows-forms-designer

我需要使用C#windows Form应用程序检索Firefox历史记录(url)。

我正在使用Firefox 17.0.1版本。

我已经尝试使用DDEClient类和SQLLite数据库。两者都不起作用。

当我使用DDEClient类时,我可以从Firefox获取活动标签页,当我使用SQLLite数据库时,它无法正常运行VS2010。

我如何达到这个要求?

1 个答案:

答案 0 :(得分:0)

private static Logger logger = LogManager.GetCurrentClassLogger();
private static string dbName = "places.sqlite";
private static int dbColumnUrl = 1;
private static int dbColumnVisitDate = 9;

String strConnection = @"Data Source=" + newPath + @";Version=3;";

using (SQLiteConnection connection = new SQLiteConnection(strConnection))
{
    string query = "select * from moz_places;";
    using (SQLiteCommand cmd = new SQLiteCommand(query, connection))
    {
        connection.Open();

        using (SQLiteDataReader dr = cmd.ExecuteReader())
        {
            while (dr.Read())
            {
                logger.Info("time: " + dr.GetValue(dbColumnVisitDate));
                logger.Info("URL: " + dr.GetValue(dbColumnUrl));
            }
        }
    }
}