i am trying to create an application in c# that would allow me to view the messages in facebook messenger. but i found that the database folder of facebook messenger contains mostly of journal and -uid files. is there any way to open these files from c#? my code so far
private void treeView1_AfterSelect_1(object sender, TreeViewEventArgs e) { var selectednode = treeView1.SelectedNode; if (selectednode.Parent == null) { string p1 = @"C:\Users\user\Desktop\acquisition\";
string p2 = @"\databases";
string path1 = p1 + treeView1.SelectedNode.Text;
string path2 = path1 + @"\databases";
string[] files = Directory.GetFiles(path2);
foreach (string file in files)
{
FileInfo f2 = new FileInfo(file);
treeView1.SelectedNode.Nodes.Add(f2.Name);
}
}
else
{
string p5 = @"C:\Users\user\Desktop\acquisition\";
string p6 = selectednode.Parent.Text;
string path1 = p5 + p6;
string path2 = path1 + @"\databases\";
string path3 = path2 + treeView1.SelectedNode.Text;
string ext = Path.GetExtension(path3);
if (selectednode.Parent.Parent == null)
{
SQLiteConnection m_dbConnection;
m_dbConnection = new SQLiteConnection("Data Source=" + path3);
m_dbConnection.Open();
if (m_dbConnection.State == ConnectionState.Open)
{ MessageBox.Show("Connected to Database"); }
string sql = "SELECT * FROM sqlite_master WHERE type ='table'";
SQLiteCommand command = new SQLiteCommand(sql, m_dbConnection);
SQLiteDataReader reader = command.ExecuteReader();
List<string> tables = new List<string>();
while (reader.Read())
{
//TreeNode node = new TreeNode(reader["name"].ToString());
treeView1.SelectedNode.Nodes.Add(reader["name"].ToString());
}
m_dbConnection.Close();
}
else if (selectednode.Parent.Parent.Parent == null)
{
SQLiteConnection m_dbConnection;
string pa5 = @"C:\Users\user\Desktop\acquisition\";
string pa6 = selectednode.Parent.Parent.Text;
string patha1 = pa5 + pa6;
string patha2 = patha1 + @"\databases\";
string pa7 = selectednode.Parent.Text;
string patha3 = patha2 + pa7;
//string pa8 = selectednode.Text;
string patha4 = patha3 + treeView1.SelectedNode.Text;
m_dbConnection = new SQLiteConnection("Data Source=" + patha3);
//m_dbConnection = new SQLiteConnection("Data Source=contacts_db2; Version=3;");
m_dbConnection.Open();
string sql;
//SqlDataAdapter da;
DataTable dt;
sql = "SELECT * FROM " + treeView1.SelectedNode.Text;
SQLiteCommand command = new SQLiteCommand(sql, m_dbConnection);
command.ExecuteNonQuery();
SQLiteDataAdapter datap = new SQLiteDataAdapter(command);
//abc = your table name
//Provide Statement to Command Object
//Create New Datatable to fill with data
dt = new DataTable("+ treeView1.SelectedNode.Text +");
//Create DataAdapter to fill data in DataTable via Adapter
datap.Fill(dt);
//gridView1 = Your GridView Name
dataGridView1.DataSource = dt.DefaultView;
datap.Update(dt);
m_dbConnection.Close();
}[![enter image description here][1]][1]
Aucun commentaire:
Enregistrer un commentaire