My question is why when using FileSystemWatcher Class to monitor when an excel file is saved the FileSystemEventArgs returnes .Deleted ? When monitoring .txt f开发者_开发技巧ormat file it is .Changed
I suppose: because the Excel first creates a temporary file, writes the information there, than deletes the original .xls file and renames the temporary file.
It might be that Excel ensures this way that the original file is not lost if save operation fails.
It looks like Excel may well be deleting and re-creating the file you're watching. One way to prove this empirically is to have your application that watches the file running and then open and save the file in another application, for example Notepad. If this only results in the Changed
event being triggered, then it's Excel causing the Deleted
event to trigger.
精彩评论