function Events() // returns an array of event objects

Each event object is defined as follows:
TimeStamp JSTime // timestamp of when the event happened (in JavaScript Date() compatible format)
Event     string // file system event as string: CREATE, WRITE, REMOVE, RENAME, CHMOD
Object    string // the file system object (file or directory) affected by Event

This FsWatcher method is designed to be called within the scope of an endless loop, to keep the script running forever (unless terminated by an admin or an OS signal). Each time this method is called, it returns an array of pending, to-be-handled, file system notifications. Every call to this method will also clear the pending notifications, so all events that are left un-handled will not be notified again.


 ConsoleFeedback = true;
 var scli = new SftpClient();
 scli.Host = '';
 scli.User = 'some_username';
 scli.PassFromSecret = 'name_of_the_secret_password';
 if (scli.Connect()) {
  watchr = new FsWatcher();
  watchr.WatchDir('C:\\Docs', true);
  while (true) {
   if (HaltSignalReceived) {
   evt = watchr.Events() // gets the list of pending events to be handled
   if (evt.length > 0) {
    for (var i = 0; i < evt.length; i++) {
     if (evt[i].Event == 'WRITE') {
      scli.UploadWithPath(evt[i].Object, '/realtimebackup', 0);
 scli = nil;