Dispose FileSystemWatcher instance before creating another in FileDialog

This commit is contained in:
Thomas Nind
2022-03-25 13:12:59 +00:00
parent 2414fcb11f
commit 5739a45f9b

View File

@@ -51,6 +51,10 @@ namespace Terminal.Gui {
bool valid = false;
try {
dirInfo = new DirectoryInfo (value == null ? directory.ToString () : value.ToString ());
// Dispose of the old watcher
watcher?.Dispose ();
watcher = new FileSystemWatcher (dirInfo.FullName);
watcher.NotifyFilter = NotifyFilters.Attributes
| NotifyFilters.CreationTime