C# 利用FileSystemWatcher监控文件的创建或修改
FileSystemWatcher fsw = new FileSystemWatcher();
fsw.Path = filePath;
fsw.Filter = filter;//每种文件
fsw.Changed += new FileSystemEventHandler(OnProcess);
fsw.Created += new FileSystemEventHandler(OnProcess);
fsw.Deleted += new FileSystemEventHandler(OnProcess);
fsw.EnableRaisingEvents = true;
fsw.NotifyFilter = NotifyFilters.DirectoryName | NotifyFilters.FileName | NotifyFilters.LastWrite | NotifyFilters.Size;
fsw.IncludeSubdirectories = true;
在文件整体创建过程中只监控到了文件名带有$(如$监控测试.doc)的文件的创建、修改和删除。正式文件(文件监控测试.doc)没有被监控到
不知道是什么原因,哪位了解这个?
这个是word编辑的时候临时创建保存,为了防止文档信息丢失,一般情况下,关闭文档后,该文档会自动消失。你看看是不是点击保存关闭会触发更改