-1

I'm working with FilesysteWatcher in the .net framework for some time, and they are pretty straightforward. Something though is happening that I cannot understand. I'm implementing something really simple to monitor a folder for XML files.

Once I get one, I get the file, I read it and I start doing things. Pretty simple. Everything works as long as I don't drop too many files at once. As long as I drop <15-20, everything works, if I go over, the first one is managed (I see the event fired), but after that, the only way to receive events again is to kill the process, and restart it.

Did I miss something obvious? This is how I instantiate my watcher:

fsw = new FileSystemWatcher(sourcePath, "*.xml")
                {
                    EnableRaisingEvents = true
                };
        
                fsw.NotifyFilter =NotifyFilters.LastAccess | NotifyFilters.LastWrite | NotifyFilters.FileName;
                fsw.Created += OnCreated;
                fsw.IncludeSubdirectories = false;
                fsw.InternalBufferSize = 64000; 

Thanks,

ff8mania
  • 1,454
  • 3
  • 16
  • 27
  • 3
    https://docs.microsoft.com/en-us/dotnet/api/system.io.filesystemwatcher.error?view=net-6.0 – Hans Passant Jun 02 '22 at 22:50
  • Any suggestion on how to manage it? I don't have control on how many files will be dumped. Do you have any strategy I can use to workaround it? – ff8mania Jun 02 '22 at 23:05
  • 1
    You'll have to identify the problem first. Once done, you'll surely have a very, very different question than the one you asked today. – Hans Passant Jun 02 '22 at 23:11
  • The problem was "System.IO.InternalBufferOverflowException: Too many changes at once in directory" thanks to your suggestion. But I don't understand what different question I should ask. I receive files (that I have no control on), and I need to process them – ff8mania Jun 02 '22 at 23:57
  • 1
    Check this https://stackoverflow.com/a/35432077/18452174 – Victor Jun 03 '22 at 07:59

0 Answers0