protected override void OnStart(string[] args) { var config = new Config(); var hour = int.Parse(config.ReadValue("Interval", "6")); _syncTimer = new Timer(state => { var ftp = new FTP(config.ReadValue("Host"), config.ReadValue("User"), config.ReadValue("Pwd")); var mode = config.ReadValue("Mode"); var isDel = config.ReadValue("IsDeleteFile") == "true" ? true : false; if (mode == "sync") { ftp.Sync(config.ReadValue("RemotePath"), config.ReadValue("LocalPath"), isDel); } else { ftp.Backup(config.ReadValue("RemotePath"), config.ReadValue("LocalPath"), isDel); } }, null, TimeSpan.FromSeconds(10), TimeSpan.FromHours(hour)); }