Delay notifications

.DelayBySeconds(seconds: number) // default: 0 (no delay)

This property of the RemoteWatcher object causes a delay of the specified number of seconds to all file-system event notifications.

This can be extremely useful to allow the OS enough time to complete file operations before the RemoteWatcher notifies our script and triggers the execution of a file transfer operation, for example.

Example:

{
  ConsoleFeedback = true;
  var scli = new SftpClient();
  scli.Host = 'your.sftpserver.com:22';
  scli.User = 'some_username';
  scli.PassFromSecret = 'name_of_the_secret_password';
  if (scli.Connect()) {
    watchr = new RemoteWatcher(scli);
    watchr.WatchDir('/Docs', true);
    watchr.DelayBySeconds = 25; // delay notifications by 25 secs.
    watchr.InclusionFilter = ['*.docx', '*.xlsx']
    watchr.ExclusionFilter = ['some_private_document.docx']
    watchr.Start();
    while (true) {
      Sleep(30000);
      if (HaltSignalReceived()) {
        break;
      }
      evt = watchr.Events()
      if (evt.length > 0) {
        for (var i = 0; i < evt.length; i++) {
          if (evt[i].Event == 'CREATE') {
            scli.DownloadWithPath(evt[i].Object, 'C:\\MyLocalCopies', 0);
          }
        }
      }
    }
    scli.Close();
  }
  scli = null;
}