1
1
// Copyright (c) 2024 Files Community
2
2
// Licensed under the MIT License. See the LICENSE.
3
3
4
+ using Files . Shared . Extensions ;
4
5
using System . Security . Principal ;
5
6
6
7
namespace Files . App . Storage . Watchers
@@ -15,9 +16,6 @@ public class RecycleBinWatcher : ITrashWatcher
15
16
/// <inheritdoc/>
16
17
public event EventHandler < SystemIO . FileSystemEventArgs > ? ItemDeleted ;
17
18
18
- /// <inheritdoc/>
19
- public event EventHandler < SystemIO . FileSystemEventArgs > ? ItemChanged ;
20
-
21
19
/// <inheritdoc/>
22
20
public event EventHandler < SystemIO . FileSystemEventArgs > ? ItemRenamed ;
23
21
@@ -35,16 +33,13 @@ public RecycleBinWatcher()
35
33
/// <inheritdoc/>
36
34
public void StartWatcher ( )
37
35
{
38
- // NOTE:
39
- // SHChangeNotifyRegister only works if recycle bin is open in File Explorer.
40
- // Create file system watcher to monitor recycle bin folder(s) instead.
36
+ // NOTE: SHChangeNotifyRegister only works if recycle bin is open in File Explorer.
41
37
42
38
// Listen changes only on the Recycle Bin that the current logon user has
43
39
var sid = WindowsIdentity . GetCurrent ( ) . User ? . ToString ( ) ?? string . Empty ;
44
40
if ( string . IsNullOrEmpty ( sid ) )
45
41
return ;
46
42
47
- // TODO: Use IStorageDevicesService to enumerate drives
48
43
foreach ( var drive in SystemIO . DriveInfo . GetDrives ( ) )
49
44
{
50
45
var recyclePath = SystemIO . Path . Combine ( drive . Name , "$RECYCLE.BIN" , sid ) ;
@@ -53,7 +48,7 @@ public void StartWatcher()
53
48
! SystemIO . Directory . Exists ( recyclePath ) )
54
49
continue ;
55
50
56
- // NOTE: Supress #15808
51
+ // NOTE: Suppressed NullReferenceException caused by EnableRaisingEvents in #15808
57
52
SafetyExtensions . IgnoreExceptions ( ( ) =>
58
53
{
59
54
SystemIO . FileSystemWatcher watcher = new ( )
0 commit comments