Ejemplo n.º 1
0
 /************************************************
 * CONSTRUCTORS
 ************************************************/
 public FswatcherChangeTimeout(Fswatcher CALLER, FileSystemEventArgs ARGS, FSEventType TYPE, int TIMEOUT)
 {
     __caller = CALLER;
     __type = TYPE;
     __fseventargs = ARGS;
     __timer.AutoReset = false;
     __timer.Interval = TIMEOUT;
     __timer.Elapsed += new ElapsedEventHandler(onTimerElapsed);
 }
Ejemplo n.º 2
0
        public void RunInteractive(string PATH="", bool RECURSE=false, bool ONCREATE=true, bool ONCHANGE=true, bool ONDELETE=true, bool ONRENAME=true, bool ONERROR=true, int CHANGETIMEOUT=250)
        {
            //create new filesystemwatcher wrapper object
            Fswatcher watcher = new Fswatcher(PATH, "*.*", RECURSE, false, CHANGETIMEOUT);

            //setup callback methods
            FSEventCallback fseventcallback = delegate(FileSystemEventArgs e, FSEventType type)
            {
                Console.WriteLine(@"{0} {1} ""{2}""", e.ChangeType, type, e.FullPath);
            };
            FSRenamedCallback fsrenamedcallback = delegate(RenamedEventArgs e, FSEventType type)
            {
                Console.WriteLine(@"{0} {1} ""{2}"" ""{3}""", e.ChangeType, type, e.OldFullPath, e.FullPath);
            };
            FSErrorCallback fserrorcallback = delegate(ErrorEventArgs e)
            {
                Console.WriteLine(@"{0} {1} ""{3}""", "ERROR", e.GetException().Message );
            };

            //setup callbacks
            if(ONCREATE)
            {
                watcher.RegisterFSCreatedCallback(fseventcallback);
            }
            if(ONCHANGE)
            {
                watcher.RegisterFSChangedCallback(fseventcallback);
            }
            if(ONDELETE)
            {
                watcher.RegisterFSDeletedCallback(fseventcallback);
            }
            if(ONRENAME)
            {
                watcher.RegisterFSRenamedCallback(fsrenamedcallback);
            }
            if(ONERROR)
            {
                watcher.RegisterFSErrorCallback(fserrorcallback);
            }

            //start the watcher
            watcher.Start();
        }