简体   繁体   中英

Watching a directory using FileSystemWatcher

Hello I'm watching a directory using FileSystemWatcher.

When a file is created into that directory - my watcher grabs and transfers it to the network drive. 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 and also could not find when I should move these file to the network drive.

Temporary files have file attribute that cite it. You can check for this attribute if the FileInfo.Attributes

check this FileAttributes

If I'm not mistaking, those temporary files are hidden files. If that doesn't work, you might consider allowing files with special names (those temporary files start with a tilde ~) to be ignored by your program. Using Regular Expressions you could set more "ignore masks" like that.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM