public Pressets SettingsJson() { Pressets parsed = new Pressets(); if (File.Exists("Setting.json")) { parsed = JsonConvert.DeserializeObject <Pressets>(File.ReadAllText("pressets.json")); } return(parsed); }
public Pressets SettingsXML() { Pressets parsed = new Pressets(); if (File.Exists("conf.xml")) { XmlDocument xml = new XmlDocument(); xml.Load("conf.xml"); foreach (XmlNode n in xml.SelectNodes("Settings")) { string Sdir = n.SelectSingleNode("sourceDir").InnerText; string Tdir = n.SelectSingleNode("targetDir").InnerText; string Ddir = n.SelectSingleNode("DearchivetDir").InnerText; parsed.sourceDir = Sdir; parsed.targetDir = Tdir; parsed.DearchiveDir = Ddir; } } return(parsed); }
public Logger() { if (File.Exists(@"C:\Users\User\source\repos\C#\2 kurs\3\3\LABA3\conf.xml")) { Presset = Parser.SettingsXML(); } else if (File.Exists(@"C:\Users\User\source\repos\C#\2 kurs\3\3\LABA3\pressets.json")) { Presset = Parser.SettingsJson(); } else { LogTxt("default config applied \n\r"); } Watcher = new FileSystemWatcher(Presset.sourceDir); Watcher.IncludeSubdirectories = true; Watcher.EnableRaisingEvents = true; Watcher.Created += FSW_Created; Watcher.Deleted += FSW_Deleted; Watcher.Renamed += FSW_Renamed; Watcher.Changed += FSW_Changed; }