文件系统观察器问题
我有一个 Windows 服务,它有一个 FileSystemWatcher
,它监视日志文件夹中的 txtfiles 更改。
每次将日志行写入 txtfile 时,它都会触发 onChanged
事件,我开始读取该文件并检索该行,然后以某种方式处理它,问题是:
事件不会被触发,除非:
-i 使用 Windows 资源管理器打开文件夹 -我继续按刷新(f5),
如果我不这样做,事件就不会被触发!
I have a windows service which has a FileSystemWatcher
which watch a log folder for txtfiles changes.
it fires onChanged
Event every time a logline gets written to a txtfile , i start reading for that file and i retrieve that line and then process it some way, the problem is :
the events doesnt get fired unless :
-i open the folder with windows explorer
-i keep pressing refresh (f5)
if i dont do that the events doesnt get fired !
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
有时,当文件的内部缓冲区未刷新时,可能会发生这种情况。写入后尝试刷新流。
Sometimes this might happen when the internal buffer of the file is not flushed. Try flushing the stream after you write to it.