我想要谷歌瀏覽器的歷史鏈接,當我搜索時,我找到了谷歌瀏覽器的“歷史”文件。但我無法讀取“歷史”文件,因為 Google Chrome 使用此“歷史”文件。因此,首先我復制了“歷史”文件,然后閱讀了我復制的“歷史”文件。它只工作了一次。因為當我第二次想要歷史鏈接時,我得到“另一個進程使用的文件”錯誤(因為它無法刪除)。private void button1_Click(object sender, EventArgs e){ listBox1.Items.Clear(); string userName = Environment.UserName; string confilename = string.Format(@"Data Source=C:\Users\{0}\Desktop\History1827", userName); string oldfilename = string.Format(@"C:\Users\{0}\AppData\Local\Google\Chrome\User Data\Default\History", userName); string newfilename = string.Format(@"C:\Users\{0}\Desktop\History1827", userName); File.Copy(oldfilename, newfilename); // I copy oldfile to newfile destination using (SQLiteConnection connection = new SQLiteConnection(confilename)) { connection.Open(); SQLiteCommand command1 = new SQLiteCommand(); command1.Connection = connection; command1.CommandText = "Select * From urls"; SQLiteDataReader dr = command1.ExecuteReader(); string historylinks = ""; while (dr.Read()) { // dr[0] = ID of Link , dr[1] = Link , dr[2] = Title of Link historylinks = dr[0].ToString() + "\t--->" + dr[1].ToString(); // I get ID and Link from History file that i copied listBox1.Items.Add(historylinks); } dr.Close(); connection.Close(); } if (File.Exists(newfilename)) { File.Delete(newfilename); MessageBox.Show("Deleted"); }}錯誤 :File.Delete(newfilename);有效。所以,如果我不使用 SQLiteConnection,程序可以刪除它復制的“歷史”文件。誰使用了這個被復制的“歷史”文件?我該如何解決?
添加回答
舉報
0/150
提交
取消