Windows - receive a warning when creating a file

I am not sure that what I ask is possible, but I would like to do the following: When a file is created in a specific folder (Windows), my program should respond. I would like to let Windows call the callback method when creating the file.

Another option is, of course, just use a loop and constantly check if the new file is in the folder, but I would like to know it instantly, so the callback method will be much more efficient.

Is it possible? The language is not important, although Java is preferable.

+5
source share
3 answers

Java nio 2 ( Java 1.7 +) "" , .

, , WatchService API.

+7

Commons IO FileAlterationListener, onDirectoryChange. , Java 1.7 .

+1

If you are not tied to Java, you can use the very convenient FileSystemWatcher in C # or VisualBasic. This will allow you to monitor all the events that may occur in the folder, and it is quite easy to implement.

0
source

All Articles