[Mono-list] FileSystemWatcher() problem ..??

Ben Maurer bmaurer@users.sourceforge.net
Thu, 08 Jan 2004 23:48:39 -0500


We have not implemented this class yet.

On Thu, 2004-01-08 at 23:37, Kieren Drapala wrote:
> Hello,
> 
> I'm a newbie to mono and I'm struggling with the use of the object
> FileSystemWatcher() on Linux version 2.4.23 (gcc version 3.3.2
> (Debian)) running mono 0.29 Mono JIT compiler version 0.29, (C) 2002,
> 2003 Ximian, Inc.
> 
> The code doesn't pick up on any events I have setup.
> Should I have FAM daemon installed ?
> 
> Heres the code I'm trying to use, and it all compiles ok.
> 
> 
> using System;
> using System.IO;
> 
> public class Watcher
> {
> 
>    public static void Main()
>    {
> 
>       try
>       {
> 
>      
>       // Create a new FileSystemWatcher and set its properties.
>       FileSystemWatcher watcher = new FileSystemWatcher();
>       watcher.Path = @"/home/kieren/BP_IN/"; 
> 
>    
>       
>       /* Watch for changes in LastAccess and LastWrite times, and
>            the renaming of files or directories. */
>       watcher.NotifyFilter =   NotifyFilters.FileName |
> NotifyFilters.LastWrite | NotifyFilters.Size |
> NotifyFilters.DirectoryName;  
> 
>       watcher.Filter = "";    //"*.*";
> 
>       // Add event handlers.
>       watcher.Changed += new FileSystemEventHandler(OnChanged);
>       watcher.Created += new FileSystemEventHandler(OnChanged);
>       watcher.Deleted += new FileSystemEventHandler(OnChanged);
>       watcher.Renamed += new RenamedEventHandler(OnRenamed);
> 
>       // Begin watching.
>       watcher.EnableRaisingEvents = true;
> 
>       // Wait for the user to quit the program.
>       Console.WriteLine("Press \'q\' to quit the sample.");
>       while(Console.Read()!='q');
>       }
>       catch (Exception ex)
>       {
>          Console.WriteLine(ex.Message);
>       }
>    }
> 
>    // Define the event handlers.
>    public static void OnChanged(object source, FileSystemEventArgs e)
>    {
>       try
>       {
>          // Specify what is done when a file is changed, created, or
> deleted.
>          Console.WriteLine("File: " +  e.FullPath + " " +
> e.ChangeType);
>       }
>       catch (Exception ex)
>       {
>          Console.WriteLine(ex.Message);
>       }
>    }
> 
>    public static void OnRenamed(object source, RenamedEventArgs e)
>    {
>       try
>       {
>       // Specify what is done when a file is renamed.
>       Console.WriteLine("File: {0} renamed to {1}", e.OldFullPath);
> //, e.FullPath);
>       }
>       catch (Exception ex)
>       {
>          Console.WriteLine(ex.Message);
>       }
>    }
> }
> 
> 
> Please advise, or any reference / example material on
> FileSystemWatcher I should be looking at, thanks in advance, regards, 
> 
> 
> 
> Kieren Drapala
> Analyst / Programmer
> The System Works Pty Ltd
> 
> 
>