@@ -25,14 +25,27 @@ public QuickAccessManager()
2525
2626		public  void  Initialize ( ) 
2727		{ 
28- 			PinnedItemsWatcher  =  new ( ) 
28+ 			var  automaticDestinationsPath  =  Path . Join ( Environment . GetFolderPath ( Environment . SpecialFolder . ApplicationData ) ,  "Microsoft" ,  "Windows" ,  "Recent" ,  "AutomaticDestinations" ) ; 
29+ 			
30+ 			// Only initialize FileSystemWatcher if the directory exists 
31+ 			// This handles cases where AppData is redirected to network locations that don't contain Windows system directories 
32+ 			if  ( Directory . Exists ( automaticDestinationsPath ) ) 
2933			{ 
30- 				Path  =  Path . Join ( Environment . GetFolderPath ( Environment . SpecialFolder . ApplicationData ) ,  "Microsoft" ,  "Windows" ,  "Recent" ,  "AutomaticDestinations" ) , 
31- 				Filter  =  "f01b4d95cf55d32a.automaticDestinations-ms" , 
32- 				NotifyFilter  =  NotifyFilters . LastAccess  |  NotifyFilters . LastWrite  |  NotifyFilters . FileName 
33- 			} ; 
34- 
35- 			PinnedItemsWatcher . Changed  +=  PinnedItemsWatcher_Changed ; 
34+ 				PinnedItemsWatcher  =  new ( ) 
35+ 				{ 
36+ 					Path  =  automaticDestinationsPath , 
37+ 					Filter  =  "f01b4d95cf55d32a.automaticDestinations-ms" , 
38+ 					NotifyFilter  =  NotifyFilters . LastAccess  |  NotifyFilters . LastWrite  |  NotifyFilters . FileName 
39+ 				} ; 
40+ 
41+ 				PinnedItemsWatcher . Changed  +=  PinnedItemsWatcher_Changed ; 
42+ 			} 
43+ 			else 
44+ 			{ 
45+ 				// If the directory doesn't exist (e.g., redirected AppData), skip FileSystemWatcher initialization 
46+ 				// The app will still function, but won't receive automatic updates when pinned items change externally 
47+ 				PinnedItemsWatcher  =  null ; 
48+ 			} 
3649		} 
3750
3851		private  void  PinnedItemsWatcher_Changed ( object  sender ,  FileSystemEventArgs  e ) 
0 commit comments