-2

I'm writing program whose purpose to count files in specified directory and when appear new files it should get this file name and store it. My question is how do i use functions like: FindFirstChangeNotification function

My OS is Windows7, also i have installed boost c++ libs.

@Jonathan Henson thanks i'll remember, i'm 1st time here so i need a time to accustom.

mistgun
  • 1
  • 1
  • 1

2 Answers2

2

You can use FindFirstChangeNotification function in Windows.

Creates a change notification handle and sets up initial change notification filter conditions. A wait on a notification handle succeeds when a change matching the filter conditions occurs in the specified directory or subtree. The function does not report changes to the specified directory itself.

etr
  • 1,252
  • 2
  • 8
  • 15
0

The easiest, simplest way is to just loop over all of the files in a directory on some sort of timer or separate thread. Maintain a set of all files from each run. When you find a file not in the set, fire off an event to your user and then add that file to your set.

As to the particulars, that depends on the OS or whether or not you are using boost or something like that.

In addition to @etr's answer, here is how you can implement this with and without boost:

How can I get the list of files in a directory using C or C++?

Community
  • 1
  • 1
Jonathan Henson
  • 8,076
  • 3
  • 28
  • 52
  • I don't really get it :/ Can U guys give any examples? – mistgun Jul 14 '14 at 18:39
  • @mistgun This is not really the platform for us to write your code for you. If you have a specific question then we can help with that. For example, "How can I list all files in a directory" would be a good question. Then, "How do I create a thread to poll such and such object?" would be another. If you are using windows, and you aren't going for platform independent, etr's answer is by far the easiest to implement. So you could ask a question like "How do I use the FindFirstChangeNotification function in windows?" – Jonathan Henson Jul 14 '14 at 19:58