I'm using the new feature of Java7 for watching directories for changes (as it is described in the following tutorial: http://download.oracle.com/javase/tutorial/essential/io/notification.html )
The watching itself works (nearly) without problems.
More or less I have two issues and I hope some of you have an idea how to handle it.
After a folder is added to watch, the VM has access to it and it doesn't release it. This should not be such a big issue. But if you're creating a directory in another directory and in this one more. (e.g. you create in directory
c:\tmp\athe directoryband inbthe directoryc(c:\tmp\a\b\c)) it is not possible to delete the directorya, because of the access of the VM tobandc. If you want to delete all of the folders (e.g., with your Windows Explorer) you have to deletecfirst, thenband thena. It's strange, but this way works (though is inconvenient)This issue seems to be a result of the first one. If many changes in
aoccur sometimes (more or less) I get an exception which tells me, the newly created folder is used by another process and it is not possible to access it. It's strange, because I think this should not matter to get a notification. And because it is not completely clear when exactly this exception is thrown.
Do you have an idea how to make it possible to not have the lock or at least to let the user the ability to delete such a directory structure in the classical convenient way?