help with registering for events from Windows

Hi,

Im developing a P2P backup system for LANs in Java. I have the following problem

Lets say there is a file called test.txt in my Windows file system. My software is running on Windows at this time. The user opens up the file through Windows Explorer and modifies it or deletes it altogether.

Is there a way I can ask WIndows to alert my software when this happens.? Essentially I need a way to give a list of files to Windows and then listen for any activity on those files

Many thanks for your help and time

[543 byte] By [aybhavea] at [2007-11-27 0:02:00]
# 1

You can do this two ways.

First, you make use of the Java Native Interface. Write a native library for Windows that uses the .NET class, FileSystemWatcher.

This next one isn't the greatest approach. It's more a brute force way, but it still works. Write your own FileSystemListener class that gets a list of files, and checks the timestamp of it's last modification and compares the two.

kmangolda at 2007-7-11 15:53:52 > top of Java-index,Security,Event Handling...
# 2

Thanks for your reply.

Can you please provide some more details about JNI. I am unable to find any quick tutorials on this topic on the Web. Most of them refer to the book. I have never heard of this before, so if you can provide a link that quickly explains file system interfaces, that would be very helpful.

aybhavea at 2007-7-11 15:53:52 > top of Java-index,Security,Event Handling...
# 3
JNI http://www.acm.org/crossroads/xrds4-2/jni.htmlFileSystemWatcher http://msdn2.microsoft.com/en-us/library/system.io.filesystemwatcher(VS.71).aspx.NET and JNI http://www.devx.com/interop/Article/19845/1954?pf=true
kmangolda at 2007-7-11 15:53:52 > top of Java-index,Security,Event Handling...