Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I Monitor Text File Changes with C++? Difficulty: No .NET

Use case: 3rd party application wants to programatically monitor a text file being generated by another program. Text file contains data you want to analyze as it's being updated.

I'm finding a lot of answers to this question wrapped around FileSystemWatcher but let's say you are writing an application for a Windows machine and can't guarantee .NET is installed.

Are there any libraries out there available for this, or am I just going to have to roll my own solution then?

Thanks.

like image 597
scubabbl Avatar asked Dec 08 '22 08:12

scubabbl


1 Answers

You can monitor a directory with FindFirstChangeNotification works on any windows.
It's efficent if you know where the file is - otherwise you can use the virtual driver/Filemon described below to check for changes anywhere on the system.

Example code here

like image 131
Martin Beckett Avatar answered Dec 11 '22 10:12

Martin Beckett