Skip to content

Commit 8260de7

Browse files
authored
Fix: Fixed FileNotFoundException in Recycle Bin watcher (#15808)
1 parent 38fe3fb commit 8260de7

File tree

1 file changed

+14
-11
lines changed

1 file changed

+14
-11
lines changed

src/Files.App/Utils/RecycleBin/RecycleBinManager.cs

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -51,18 +51,21 @@ private void StartRecycleBinWatcher()
5151
if (drive.DriveType == SystemIO.DriveType.Network || !SystemIO.Directory.Exists(recyclePath))
5252
continue;
5353

54-
SystemIO.FileSystemWatcher watcher = new()
54+
SafetyExtensions.IgnoreExceptions(() =>
5555
{
56-
Path = recyclePath,
57-
Filter = "*.*",
58-
NotifyFilter = SystemIO.NotifyFilters.LastWrite | SystemIO.NotifyFilters.FileName | SystemIO.NotifyFilters.DirectoryName
59-
};
60-
61-
watcher.Created += RecycleBinWatcher_Changed;
62-
watcher.Deleted += RecycleBinWatcher_Changed;
63-
watcher.EnableRaisingEvents = true;
64-
65-
binWatchers.Add(watcher);
56+
SystemIO.FileSystemWatcher watcher = new()
57+
{
58+
Path = recyclePath,
59+
Filter = "*.*",
60+
NotifyFilter = SystemIO.NotifyFilters.LastWrite | SystemIO.NotifyFilters.FileName | SystemIO.NotifyFilters.DirectoryName
61+
};
62+
63+
watcher.Created += RecycleBinWatcher_Changed;
64+
watcher.Deleted += RecycleBinWatcher_Changed;
65+
watcher.EnableRaisingEvents = true;
66+
67+
binWatchers.Add(watcher);
68+
});
6669
}
6770
}
6871

0 commit comments

Comments
 (0)