1

I have created a File watcher for watching the directory and files, here I could get a change event when files are replaced. but for directory only created event triggers not replaced event. How to get the event of replaced on directory replace? my added events

 watcher = new FileSystemWatcher();
        watcher.Path = folder+@"INPUT\";

        watcher.NotifyFilter = System.IO.NotifyFilters.DirectoryName;
        watcher.NotifyFilter = watcher.NotifyFilter | System.IO.NotifyFilters.FileName;
        watcher.NotifyFilter = watcher.NotifyFilter | System.IO.NotifyFilters.Attributes;
       
        watcher.Changed += new FileSystemEventHandler(eventRaised);
        watcher.Created += new FileSystemEventHandler(eventRaised);
       
        watcher.IncludeSubdirectories = true;
        watcher.EnableRaisingEvents = true;
        watcher.Error += new ErrorEventHandler(OnError);
        
Useme Alehosaini
  • 2,998
  • 6
  • 18
  • 26
Santhosh Nayak
  • 2,312
  • 3
  • 35
  • 65
  • What do you mean by "replaced"? Perhaps you're thinking about [renaming](https://learn.microsoft.com/en-us/dotnet/api/system.io.filesystemwatcher.renamed)? – Xerillio Dec 19 '20 at 13:29
  • folder with same name placed with with different files. – Santhosh Nayak Dec 19 '20 at 13:33
  • 2
    That's not an operation you can perform on a filesystem directly. That would be a combination of deleting the folder with its contents and then creating a new folder (with the same name) and its files. – Xerillio Dec 19 '20 at 13:38

0 Answers0