0

I have fileWatcher object which watches to Local user Temp Folder (~/AppData/Local/Temp). Code below works fine if file watcher watches, for example, for D drive. But it does not raise if I watch for local user temp folder.

var fileWatcher = new FileSystemWatcher();
fileWatcher.Path = Path.GetTempPath();
fileWatcher.NotifyFilter = NotifyFilters.LastWrite;
fileWatcher.Filter = "*.pvm";
fileWatcher.EnableRaisingEvents = true;
fileWatcher.Changed+= FileDetected;
Izzy
  • 6,740
  • 7
  • 40
  • 84
  • Do you have access right to that folder? – CodeTherapist Nov 02 '15 at 15:29
  • I found the following [SO question](http://stackoverflow.com/questions/1351691/filesystemwatcher-not-monitoring-local-user-folder-or-temporary-internet-files-f), which seems similar to your issue. It's not clear what the answer was exactly, but it might help you. – Jason Evans Nov 02 '15 at 15:32
  • The code you posted works fine for me. Note that writing to a file does not necessarily update the directory information immediately. Windows will defer the change for some period of time, unless some other process actively examines the file system (e.g. reads the file contents, Explorer window is refreshed, etc.). If you have a reproducible issue that involves not _ever_ receiving change notifications, please provide [a good, _minimal_, _complete_ code example](http://stackoverflow.com/help/mcve) that reliably reproduces that issue. – Peter Duniho Nov 02 '15 at 17:56

0 Answers0