Wow Microsoft… just wow.

So I’m sitting here writing some code in .NET and I have myself a File System Watcher in my code to check if a file has been changed and if it has, it’s supposed to load the file and process any changes. In this case, it’s a log file and if the log file changes anywhere else in the program the log viewing window should reload it. Seems right? Yes.

OK, so now onto the bug. Apparently there’s a bug in which the File System Watcher will fire off multiple file changed events one after another even though there was only one change to one file. Yes, that’s right. Multiple events.

So here’s the code…

Of you want a VB.NET example…

  • Dax

    This is due to way how some applications handle file writing in Windows.
    Have you tried saving file attributes and comparing those during update event ?