简体   繁体   English

监视C ++中的文件更改(Windows)

[英]monitor file changes in c++ (windows)

I have a set of files and I would like to monitor them for changes. 我有一组文件,我想监视它们的更改。
I have tried FileSystemWatcher class, but it seems notifications are fired after file is changed and then saved. 我尝试了FileSystemWatcher类,但是似乎在更改文件然后保存后会触发通知。 Say, if I monitor directory for changes in .txt files, open some file, save it FileSystemWatcher works. 说,如果我监视目录中.txt文件的更改,请打开一些文件,将其保存,FileSystemWatcher可以正常工作。 But how can I monitor changes when the file is opened and something is typed without saving? 但是,当打开文件并键入某些内容却没有保存时​​,如何监视更改? Reading original first and then reading the same file after some interval and then comparing them seems slow and stupid. 首先读取原始文件,然后间隔一段时间再读取相同的文件,然后比较它们似乎很慢而且很愚蠢。 Is there a nice way to monitor such situation? 有监视这种情况的好方法吗?

否,因为文件本身尚未更改。

不,如果您将文件读入内存并对其进行修改,那么另一个应用程序将如何知道该文件?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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