Events (to watch for)

{
  NotifyCreate: boolean // default: true
  NotifyRemove: boolean // default: true
  NotifyModify: boolean // default: true
}

These 3 properties of the RemoteWatcher object determine which remote file-system events will be included in the watcher’s notifications and which ones won’t. By default they are all set to true, so unless you want to disable some of them, you don’t need to set/reset them in your code.

NotifyCreate: used to receive notifications when an object (typically a file) is created on the remote side.

NotifyRemove: used to receive notifications when an object (typically a file) is deleted on the remote side.

NotifyModify: used to receive notifications when an object (typically a file) is modified (written-to) on the remote side.

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.NotifyRemove = false;
    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;
}