To access this in C#, you will need to read the file line by line, and determine if the line is the title, url, etc. I have come up with this code that should help you:
public IEnumerableNote: To use this, you will need to include:GetHistory(bool display) { // Get Current Users App Data string documentsFolder = GetFolder(); //If directory exists if (Directory.Exists(documentsFolder)) { //This is the line number of the history file int lineNumber = 1; //This is the history file in the documents folder string historyFile = documentsFolder + "global_history.dat"; //URL Variables string title = null; string url = null; int frequency = 0; DateTime visited = new DateTime(); //These variables tell you if each line has been parsed //and each part has been assigned bool urlAssigned = false; bool titleAssigned = false; bool frequencyAssigned = false; bool visitedAssigned = false; //The url to assign to the URL table URL u; //Create a new StreamReader using the history file //to read the file line by line System.IO.StreamReader file = new System.IO.StreamReader(historyFile); //The line that is being read string line; //While the line that is being read is being read by //file.ReadLine, and is not null while ((line = file.ReadLine()) != null) { /*This is a table of what each line is * Line 1 = The Title of the URL * Line 2 = The URL of the URL * Line 3 = The Unix Time of which the URL was visited * Line 4 = The frequency of visits, which cannot convert */ //If the line number is the first, or if the line number minus 1 //is a multiple of 4, for example, line number 5 - 1 is 4, which //is a multiple of 4 if (lineNumber == 1 || (lineNumber - 1) % 4 == 0) { Debug.WriteLine(line); title = line; titleAssigned = true; } //If line number is the second, or line number - 2 is a multiple //of 4, ex. 6 - 2 = 4, which is a multiple of 4 if (lineNumber == 2 || (lineNumber - 2) % 4 == 0) { url = line; urlAssigned = true; } //If the line number is the third, or if line number - 3 is a //multiple of 4, ex. 7 - 3 = 4 if (lineNumber == 3 || (lineNumber - 3) % 4 == 0) { //If the line is the correct length for Unix time if (line.Length == 10) { //then convert the number to a local datetime visited = FromUnixTime(Int64.Parse(line)).ToLocalTime(); } else MessageBox.Show("An error occured while parsing the date \n" + line); visitedAssigned = true; frequencyAssigned = true; } //If all of the values have been assigned if (urlAssigned == true && titleAssigned == true && frequencyAssigned == true && visitedAssigned == true) { //create a new URL with the values u = new URL(url, title, "Opera", visited, frequency); //And add the URL to the URLs array URLs.Add(u); //Reset the assigned values urlAssigned = false; titleAssigned = false; frequencyAssigned = false; visitedAssigned = false; } if (lineNumber == 4000 || file.EndOfStream == true) { MessageBox.Show("done " + URLs.Count.ToString()); } lineNumber++; } } return URLs; } private static string GetFolder() { string folder = "\\Opera\\Opera\\"; string documentsFolder = Environment.GetFolderPath (Environment.SpecialFolder.ApplicationData); documentsFolder += folder; return documentsFolder; } public DateTime FromUnixTime(long unixTime) { var epoch = new DateTime(1970, 1, 1, 0, 0, 0); return epoch.AddSeconds(unixTime); }
using System.Diagnostics; using System.IO;
This script also reuses the URL class from my post on IE history. I have commented on most parts of this, so it should be easy to understand. This is the underlying method on how to get Opera's history with C#.
If you have any more questions or comments, please let me know!
Hi Chris, I understode most of the part of your code. But I am not getting what is URL of which u are creating a new instance of and then assigning all the values to it.
ReplyDeleteswati
Hi swati,
DeleteI am not sure of exactly which line you are talking about, but what is happening is that on each line, you test if it is the first, second, third, or fourth line in each sequence. You then assign the value of each line in the sequence, and then, after four lines are executed, the new URL is created, and added to a list of URL's. If you need my URL class, see my post on IE history.
Hope it helped!
How To Access Opera History In C >>>>> Download Now
Delete>>>>> Download Full
How To Access Opera History In C >>>>> Download LINK
>>>>> Download Now
How To Access Opera History In C >>>>> Download Full
>>>>> Download LINK oH
sehr guter Beitrag
ReplyDeleteThis comment has been removed by the author.
ReplyDeleteCould you please let me know the way to get chrome and mozila history in c#
ReplyDelete