Skip to main content

How to subscribe to file changes?

Remarks

#How to subscribe to file changes?

In order to retrieve the notifications about the file changes located in a given directory use a ForFolder method.

IObservableWithTask<FileChangeNotification> ForFolder(string folder);
Parameters
folderstringThe name of a directory for which notifications will be sent.

Return Value
IObservableWithTask<FileChangeNotification>The observable that allows to add subscriptions to received notifications

Example

IDisposable subscription = store
.Changes()
.ForFolder("/documents/books")
.Subscribe(change =>
{
switch (change.Action)
{
case FileChangeAction.Add:
// do something
break;
case FileChangeAction.Delete:
// do something
break;
}
});

Remarks

To get more method overloads, especially the ones supporting delegates, please add Reactive Extensions package to your project.