How to create a file system / directory manager in VC ++?

I am new to VC ++ and programming. I have a task in which I have to design a file observer in VC ++.

The problem is as follows:

I have to constantly monitor some log files; whenever a particular log file is deleted (this removal is performed by another program), I have to open the TextFile and write some data and a timestamp to it.

How should I do it? Please, help!

+3
source share
4 answers

First you need to configure the system to monitor file events from this folder. To get started, see FindFirstChangeNotification ().

.

, , , . , , , ( ), .

-, , , , . : WaitForMultipleObjects - " " ​​ FindFirstChangeNotification. , , , , .

+1

MFC (), Win32 API, , , , . , - , , , , .

FindFirstChangeNotification ReadDirectoryChangesW .

0

Windows (WMI), . AFAIK - . __InstanceDeletionEvent, __InstanceModificationEvent __InstanceCreationEvent , , .

WMI Reference/++.

.

0

I highly recommend that you consider using here . This API is not 100% reliable, but this code does a good job of completing it. If your file traffic is local and not too frequent, it should work well for you.

0
source

Source: https://habr.com/ru/post/1783466/


All Articles