Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.IO;
- using System.Reflection;
- using System.Net;
- using System.Runtime.Serialization;
- using System.Runtime.Serialization.Formatters.Binary;
- using System.Xml.Serialization;
- public class WebUrl
- {
- private string url;
- public string urlink
- {
- get { return url; }
- set { url = value; }
- }
- }
- //mao ni event niya to automatically record history
- private void geckoWebBrowser1_Navigated(object sender, Skybound.Gecko.GeckoNavigatedEventArgs e)
- {
- WebUrl url = new WebUrl();
- url.urlink = geckoWebBrowser1.Url.ToString();
- AppendData(url, Path.GetDirectoryName(Application.ExecutablePath) + "history.bin"); //auto create na ni sya
- }
- //event to record bookmark
- private void btnSaveBookmark_Click(object sender, EventArgs e)
- {
- WebUrl url = new WebUrl();
- url.urlink = geckoWebBrowser1.Url.ToString();
- AppendData(url, Path.GetDirectoryName(Application.ExecutablePath) + "bookmark.bin"); //auto create na ni sya
- }
- public void AppendData(WebUrl url, string filename)
- {
- XmlSerializer xmlser = new XmlSerializer(typeof(List<WebUrl>));
- List<WebUrl> list = null;
- try
- {
- using (Stream s = File.OpenRead(filename))
- {
- list = xmlser.Deserialize(s) as List<WebUrl>;
- }
- }
- catch
- {
- list = new List<WebUrl>();
- }
- list.Add(url);
- using (Stream s = File.OpenWrite(filename))
- {
- xmlser.Serialize(s, list);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement