.netfilesystemwatcherbeyondcompare

Saving changes in Beyond Compare does not trigger FileSystemWatcher Changed event


This does not make any sense but, as stated in title, when a file is modified with Beyond Compare in a folder monitored by FileSystemWatcher the Changed event is not triggered.

When the same file is modified with Notepad++ the Changed event is triggered. I did verify that the file is actually changed when saving in Beyond Compare as I opened it in Notepad after saving with Beyond Compare and the changes were there.

Anyone encountered such weirdness before and any ideas why this is happening and how to get the Changed event to trigger when saving from Beyond Compare?

Standard FSW code which is IMO irrelevant:

fswDir = new FileSystemWatcher
{
    Path = dirPath,
    NotifyFilter = NotifyFilters.LastWrite,
    Filter = "*.*",
    EnableRaisingEvents = true
};

private void OnFswDirf_Changed(object sender, FileSystemEventArgs e)
{           
    var filePath = e.FullPath;
    // Not executed when file saved by BC, executed when file saved by Notepad++.
}

Solution

  • After subscribing to all FSW events and all NotifyFilter enums I managed to get the full sequence of FSW events triggered by Beyond Compare 4 File>Save function in case someone needs this in future:

    1. Created: XXXXXX.tmp file.
    2. Changed: XXXXXX.tmp file.
    3. Changed: XXXXXX.tmp file.
    4. Created: OriginalFileName.ext~XXXXXXXXX.TMP file.
    5. Changed: OriginalFileName.ext~XXXXXXXXX.TMP file.
    6. Renamed: OriginalFileName.ext file.
    7. Changed: OriginalFileName.ext~XXXXXXXXX.TMP file.
    8. Changed: OriginalFileName.ext file.

    After the process of elimination it turned out that in order to get changes made by BC NotifyFilter needs to be set to:

    NotifyFilter = NotifyFilters.LastWrite | NotifyFilters.Attributes;
    

    After that Changed event will capture the file change by BC.