static void mainSegment() { query = ""; searchQuery = ""; try { configStr = File.ReadAllText("config.xml"); } catch (FileNotFoundException ex) { Directory.CreateDirectory("cache"); XElement config = new XElement("config", new XElement("query", "car|abstract"), new XElement("interval", "12")); configStr = config.ToString(); config.Save("config.xml"); } try { string[] files = Directory.GetFiles("cache", "*.jpg"); foreach (string file in files) { File.Delete(file); } config.LoadXml(configStr); searchQuery = config.GetElementsByTagName("query")[0].InnerText; interval = Convert.ToInt32(config.GetElementsByTagName("interval")[0].InnerText); } catch (Exception ex) { File.AppendAllText("error.log", ex.Source + "-----" + ex.Message + "\r\n" + ex.ToString()); } while (true) { WallhavenParser.ParseAndSet(query, searchQuery); Thread.Sleep(interval * 1000 * 60); } }
private static void NextWallpaper_Click(object sender, EventArgs e) { WallhavenParser.ParseAndSet(query, searchQuery); }