Inclusion/Exclusion filters¶
{
InclusionFilter: []string
ExclusionFilter: []string
}
These two properties instruct the RemoteWatcher to include or exclude specific file-masks.
By default, InclusionFilter
is [‘*’], so it includes everything, while ExclusionFilter
is empty, so nothing will be excluded.
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;
// let's only include Word and Excel documents
watchr.InclusionFilter = ['*.docx', '*.xlsx']
// but exclude a specific Word document by name
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;
}