[Samba] Using samba volume with C# FileSystemWatcher class
Jeremy Allison
jra at samba.org
Fri Feb 3 20:12:52 GMT 2006
On Fri, Feb 03, 2006 at 02:30:11PM -0500, Rice, Gary wrote:
> I'm trying to monitor changes to the contents of a directory using the
> FileSystemWatcher class of MS Visual Studio C#.
>
> Here is my setup:
> Unix (Sun OS) with an nfs share pointing to a sub-directory on the local
> disk
> Windows XP (sp2) with the nfs share set up and mapped to the T: drive
> designator.
>
> Using "My Computer", I can open a window to the nfs share and see all of the
> files in the shared (unix) directory. This tells me that samba is set up
> correctly and functioning.
>
> So I wrote a small application (Visual Studio 2003) in C# that is supposed
> to watch the remote directory for changes to its contents.
>
> If I look at the C: drive (local disk on my PC), my application is
> successfully notified about changes to files on the C: drive.
>
> However when I change the code to look at the T: drive, my app never sees
> any of the changes I make to the directory contents on the T: drive.
>
> Does this sound familiar?
>
> Is there any other way besides using the FileSystemWatcher class to
> determine if the files on the nfs disk have changed via an application
> running on the PC?
Samba currently supports ChangeNotify (which is how file system notification
works) at the level of the current directory being watched *only*. Currently
we generate a "something changed, we don't know what" message when we detect
an update. Until I integrate Samba with inotify (which is a Linux specific
feature) this is the best we can do.
If you're expecting change notification on individual files (ie. file \foo
changed) or on sub-directories of the monitored directory (ie. you're monitoring
\\server\share\dir1 and something changes in \\server\share\dir1\dir2 then
you're not going to see that).
The reason is there's no easy way on POSIX to make that work. It's an incredibly
expensive operation.
Jeremy.
More information about the samba
mailing list