Example #1
0
        public Pressets SettingsJson()
        {
            Pressets parsed = new Pressets();

            if (File.Exists("Setting.json"))
            {
                parsed = JsonConvert.DeserializeObject <Pressets>(File.ReadAllText("pressets.json"));
            }
            return(parsed);
        }
Example #2
0
        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);
        }
Example #3
0
            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;
            }