当前位置: 动力学知识库 > 问答 > 编程问答 >

c# - 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.

分享给朋友:
您可能感兴趣的文章:
随机阅读: