Enumerate Edge Chromium Collections

Ward Horsfall 101 Reputation points
2022-02-08T14:11:26.833+00:00

Hi
Is there any way in c# I can enumerate Mcriosoft Edge collections?

Thanks
Ward

Microsoft Edge
Microsoft Edge
A Microsoft cross-platform web browser that provides privacy, learning, and accessibility tools.
2,114 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Yu Zhou-MSFT 12,036 Reputation points Microsoft Vendor
    2022-02-09T08:54:44.92+00:00

    Hi @Ward Horsfall

    Collections data are stored in a SQLite database in the user's browser profile. The path of Collection file is like below:

    C:\Users\UserName\AppData\Local\Microsoft\Edge\User Data\ProfileName\Collections\collectionsSQLite  
    

    When we open the SQLite database, we can see that the Collections urls are stored in items table, source column .

    172488-image.png

    Then I think you can connect to the database and read data from it using C#. You can use package System.Data.SQLite. You can refer to this thread for related code.

    Sample code:

    using System;  
    using System.Text;  
    using System.Data;  
    using System.Data.SQLite;  
      
    namespace ConsoleApp1  
    {  
        class Program  
        {  
            static void Main(string[] args)  
            {  
                DataClass dc = new DataClass();  
                dc.selectQuery(@"SELECT source FROM items");    
            }  
            class DataClass  
            {  
                private SQLiteConnection sqlite;  
      
                public DataClass()  
                {  
                    sqlite = new SQLiteConnection(@"Data Source=C:\Users\UserName\AppData\Local\Microsoft\Edge\User Data\Default\Collections\collectionsSQLite");  
                }  
                public DataTable selectQuery(string query)  
                {  
                    DataTable dt = new DataTable();  
                    SQLiteCommand selectCommand = new SQLiteCommand(query, sqlite);  
                    try  
                    {  
                        sqlite.Open();  
                        SQLiteDataReader reader = selectCommand.ExecuteReader();  
                        while (reader.Read())  
                        {  
                            var url = reader.GetString(0);  
                            Console.WriteLine(url);  
                        }  
                        sqlite.Close();  
                    }  
                    catch (SQLiteException e)  
                    {  
                        //Add your exception code here  
                    }  
                    return dt;  
                }  
            }  
        }  
    }  
    

    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    Regards,
    Yu Zhou