4 Replies Last post: Feb 6, 2008 5:13 PM by Ali Naddaf  
  5 posts since
Feb 5, 2008
Currently Being Moderated

Feb 5, 2008 11:01 PM

FileSystemWatcher and SMB shares

Hello all.

 

Will FileSystemWatcher (wrapped in the JNIWrapper) works as expected on a SMB shared drive on Windows box? I have a Java application that I want to be able to monitor a number of "watched" folders where some of which may be mapped drives (from SMB shares on linux boxes). Do I need to set something differently? My initial investigation seems to indicate that it doesn't work on that share.

 

 

 

Many thanks,

 

Ali.

Serge Piletsky TeamDev Ltd. 1,066 posts since
Apr 24, 2006
Currently Being Moderated
1. Feb 6, 2008 3:15 PM in response to: Ali Naddaf
Re: FileSystemWatcher and SMB shares

Hi Ali,

 

By default on all NT systems FileSystemWatcher uses WinNTWatcherStrategy, which is specially designed for working on NTFS file system. This strategy also works if remote share is on NTFS file system, but it will not work for another file system. You can try another watcher strategy (for example Win9xWatcherStrategy) in your case, but this implementation is less effective.

 

-Serge

Serge Piletsky TeamDev Ltd. 1,066 posts since
Apr 24, 2006
Currently Being Moderated
3. Feb 7, 2008 4:04 PM in response to: Ali Naddaf
Re: FileSystemWatcher and SMB shares

Well, I know from our support history that it's possible to monitor file events on such Samba shares using the Win9xWatcherStrategy class. At least you can try the following code to verify that:

   FileSystemWatcher watcher = new FileSystemWatcher(folder, true);
   watcher.setStrategy(Win9xWatcherStrategy.class);
   ...

 

In fact this implementation (Win9xWatcherStrategy) is more efficient than the periodic re-scanning of the watched folders, because it's based on handling file system events. Though its performance greatly depends on the size of a watched folder. And you can always tune up the performance if necessary, because there are the sources of our implementation in WinPack library.

 

-Serge

More Like This

  • Retrieving data ...