我想要谷歌浏览器的历史链接,当我搜索时,我找到了谷歌浏览器的“历史”文件。但我无法读取“历史”文件,因为 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
提交
取消