Search code examples
ms-officefilesystemwatchertemporary-files

Identifying Microsoft Office temporary files


I'm watching a directory using FileSystemWatcher.

When a file is copied into that directory - my watcher grabs it and performs multiple actions with it.

My problem is that when a Microsoft Office file is opened, a temporary file is created in the watched directory. I can't find a way to ignore these files.

Though the temporary file name is well known (i.e. abcd.docx --> ~$cd.docx), I need a better way than this to identify that file.

Any ideas?


Solution

  • These temporary files are marked as hidden.

    Therefore, you can ignore all hidden files. (Call File.GetAttributes)