.DelayBySeconds // integer number


This property of the FsWatcher 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 FsWatcher 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 FsWatcher();
  watchr.WatchDir('C:\\Docs', true);
  watchr.DelayBySeconds = 10 // delay all notifications by 10 seconds
  watchr.InclusionFilter = ['*.docx', '*.xlsx']
  watchr.ExclusionFilter = ['some_private_document.docx']
  watchr.Start(); 
  while (true) {
   Sleep(1000);
   if (HaltSignalReceived) {
    break;
   }
   evt = watchr.Events()
   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.Close();   
 } 
 scli = nil;
}