Skip to content

Commit b5ceedc

Browse files
committed
Merge branch 'master' into pr/5
2 parents 3b39cdc + d0b669d commit b5ceedc

1 file changed

Lines changed: 24 additions & 2 deletions

File tree

Source/FileWatcherEx/FileSystemWatcherEx.cs

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,27 @@ public class FileSystemWatcherEx : IDisposable
3131
public string FolderPath { get; set; } = "";
3232

3333

34+
/// <summary>
35+
/// The collection of all the filters used to determine what files are monitored in a directory.
36+
/// </summary>
37+
public System.Collections.ObjectModel.Collection<string> Filters { get; } = new();
38+
39+
3440
/// <summary>
3541
/// Filter string used for determining what files are monitored in a directory
3642
/// </summary>
37-
public string Filter { get; set; } = "*.*";
43+
public string Filter
44+
{
45+
get
46+
{
47+
return Filters.Count == 0 ? "*" : Filters[0];
48+
}
49+
set
50+
{
51+
Filters.Clear();
52+
Filters.Add(value);
53+
}
54+
}
3855

3956

4057
/// <summary>
@@ -213,7 +230,12 @@ void onError(ErrorEventArgs e)
213230
_watcher = new FileWatcher();
214231

215232
_fsw = _watcher.Create(FolderPath, onEvent, onError);
216-
_fsw.Filter = Filter;
233+
234+
foreach (var filter in Filters)
235+
{
236+
_fsw.Filters.Add(filter);
237+
}
238+
217239
_fsw.NotifyFilter = NotifyFilter;
218240
_fsw.IncludeSubdirectories = IncludeSubdirectories;
219241
_fsw.SynchronizingObject = SynchronizingObject;

0 commit comments

Comments
 (0)