FileSystemWatcher.Changed starts immediately when Excel 2007 opens an .xls file in compatibility mode

We use FileSystemWatcher to monitor documents opened from our document management system, and if the user saves the document, we ask whether they will also be updated in our system.

We have a problem with XLS files in Excel 2007 (it is not verified that the problem does not exist in 2003, but these are only files that open in compatibility mode in 2007), where the Changed event is fired immediately after the file is opened, and then again when closing a file, even if nothing has changed or the user does not want to save when closing. The same behavior does not exist when opening XLSX files.

I wrote a test application to test the behavior that you can find in ( http://www.just2guys.net/SOFiles/FSWExcel.zip ). The application has one FileSystemWatcher for each type of NotifyFilter, so it becomes obvious why the Shanged event was fired.

How can you think of only asking the user when the document is actually somehow saved by the user? I can start tracking the file after calling Process.Start, which allows me to skip the message when I open the document, but I still get it when I close the document, even if nothing has changed.

+3
source share
3 answers

, :

.doc .xls Office, .

, reset ( ont save).

, Office :

  • on Open, timestamp , ,

  • on Close, , ""

+3

. , , .

, , (Thread.Sleep) , , ( , , , , , / ).

+1

Excel , - , , , . Name FileSystemEventArgs , '~'.

0

Source: https://habr.com/ru/post/1735978/


All Articles