protected override void OnStart(string[] args) { using (StreamReader r = new StreamReader(@"C:\Users\Admin\Documents\Zalo Received Files\configure.json")) { string json = r.ReadToEnd(); //JavaScriptSerializer jss = new JavaScriptSerializer(); //List<readJson> items = jss.Deserialize<List<readJson>>(json); List <readJson> array = JsonConvert.DeserializeObject <List <readJson> >(json); foreach (var item in array) { report = item.Report_His; conStr = item.Connect_DataBase; backup = item.Backup_Report_His; error = item.Error_Report_His; } } FileSystemWatcher watcher = new FileSystemWatcher(report); watcher.EnableRaisingEvents = true; watcher.IncludeSubdirectories = true; //xu ly su thay doi cua file watcher.Changed += watcher_Changer; watcher.Created += watcher_Created; watcher.Deleted += watcher_Delete; watcher.Renamed += watcher_Renamed; Service1.readFileXML(); Console.Read(); }
protected override void OnStart(string[] args) { using (StreamReader r = new StreamReader(@"C:\Users\Admin\Documents\Zalo Received Files\configure.json")) { string json = r.ReadToEnd(); List <readJson> array = JsonConvert.DeserializeObject <List <readJson> >(json); foreach (var item in array) { report = item.Report_His; conStr = item.Connect_DataBase; backup = item.Backup_Report_His; error = item.Error_Report_His; } } if (report == "" || conStr == "" || backup == "" || error == "") { writeLog.write("Error: file configure.json", "", "", DateTime.Now); return; } FileSystemWatcher watcher = new FileSystemWatcher(report); watcher.EnableRaisingEvents = true; watcher.IncludeSubdirectories = true; //xu ly su thay doi cua file watcher.Created += watcher_Created; Service1.readFileXML(); Console.Read(); }