FileSystemWatcher & Visual Studio 2005

time to read 2 min | 227 words

Okay, I've this very strange bug. I got an application that watch over a folder for changes in the files. When I edit the files in Visual Studio 2005, the application doesn't do anything. But when I edit the file in notepad, the change event is fired and everything is fine. Anyone knows what is going on there?

Here is sample code the shows the problem:

  1. import System
  2. import System.IO
  3.  
  4. class Bug:
  5.         watch as FileSystemWatcher
  6.        
  7.         def StartWatching():
  8.                 watcher = FileSystemWatcher("""C:\Test""", Filter: "*.*")
  9.                 watcher.Changed += def(source, e as FileSystemEventArgs):
  10.                         print "${e.FullName} has changed ${DateTime.Now}"
  11.                 watcher.EnableRaisingEvents = true;
  12.                 print "Watching..."
  13.  
  14. Bug().StartWatching.BeginInvoke()
  15.  
  16. Console.Read()