public static void Store() { try { if (!Filesystem.DirectoryExists(Filesystem.UserProfile + "\\Popup Multibox")) { Filesystem.CreateDirectory(Filesystem.UserProfile + "\\Popup Multibox"); } Filesystem.FileWriteAllLines(Filesystem.UserProfile + "\\Popup Multibox\\prefs.txt", new[] { MultiboxWidth + "", ResultHeight + "", AutoCheckUpdate + "", AutoCheckFrequency + "" }); } catch { } }
public static void Store() { try { List <string> lines = new List <string>(0); lines.AddRange(items.Select(i => i.ToFileString()).Where(tmp => !tmp.Equals(";;;;;;"))); if (!Filesystem.DirectoryExists(Filesystem.UserProfile + "\\Popup Multibox")) { Filesystem.CreateDirectory(Filesystem.UserProfile + "\\Popup Multibox"); } Filesystem.FileWriteAllLines(Filesystem.UserProfile + "\\Popup Multibox\\searches.txt", lines.ToArray()); } catch { } }
public static void Load() { try { string[] lines = Filesystem.FileReadAllLines(Filesystem.UserProfile + "\\Popup Multibox\\searches.txt"); items.Clear(); foreach (string line in lines) { SearchItem tmp = SearchItem.FromFileString(line); if (tmp != null) { items.Add(tmp); } } } catch { try { List <string> lines = new List <string>(0); lines.Add("Google;;;google;;;http://www.google.com/search?q=%s"); lines.Add("Yahoo!;;;yahoo;;;http://search.yahoo.com/search?fr=crmas&p=%s"); lines.Add("Bing;;;bing;;;http://www.bing.com/search?q=%s"); lines.Add("Wikipedia;;;wiki;;;http://en.wikipedia.org/w/index.php?title=Special:Search&search=%s"); if (!Filesystem.DirectoryExists(Filesystem.UserProfile + "\\Popup Multibox")) { Filesystem.CreateDirectory(Filesystem.UserProfile + "\\Popup Multibox"); } Filesystem.FileWriteAllLines(Filesystem.UserProfile + "\\Popup Multibox\\searches.txt", lines.ToArray()); items.Clear(); foreach (string line in lines) { SearchItem tmp = SearchItem.FromFileString(line); if (tmp != null) { items.Add(tmp); } } } catch { } } }