1

Excel files are dropped manually into a local folder, there is a FileWatcher which converts the file into a new filestructure and moves it to the next folder which also have a filewatcher. The problem is that when this file is moved to the next folder the filewatcher does not fire any event. However if i cut it and drop it physically the event fires. I am using File.Move to copy file from folder1 to folder2

2 Answers2

2

you should look at FileSystemWatcher detect when file is moved to folder

Actually when there is a move, the filesystemwatcher send a delete (in the source directory watcher) and a create (in the target directory watcher).

Community
  • 1
  • 1
Robin Camus
  • 91
  • 10
0

try to use renamed event.

Another reason could be the buffer size may exceeded.

 Public void WatchItBaby()
 {
    // ...
    FileSystemWatcher watcher = new FileSystemWatcher(@"c:\temp\", "*.txt");            
    watcher.Created += new FileSystemEventHandler(OnChangedOrRenamed);          
    watcher.Renamed += new RenamedEventHandler(OnChangedOrRenamed);
    watcher.EnableRaisingEvents = true;
    // ...
 }

 private void OnChangedOrRenamed(object source, FileSystemEventArgs e)
 {
    // stuff        
 }
Dinch
  • 548
  • 4
  • 9