Exemplo n.º 1
0
 public FileWatcher(string filepath, FileChangedHandler handler)
     : base(System.IO.Path.GetDirectoryName(filepath),
     System.IO.Path.GetFileName(filepath))
 {
     FilePath = filepath;
     Handler = handler;
     NotifyFilter =
         NotifyFilters.FileName |
         NotifyFilters.Attributes |
         NotifyFilters.LastAccess |
         NotifyFilters.LastWrite |
         NotifyFilters.Security |
         NotifyFilters.Size;
     Changed += new FileSystemEventHandler(delegate(object sender, FileSystemEventArgs e)
     {
         // TODO : Find alternative !!
         /*
         System.Windows.Application.Current.Dispatcher.BeginInvoke(
             new VoidDelegate(this.FileChanged));
          */
     });
     UpdateFileInfo();
     Timer = new Timer(100);
     Timer.AutoReset = false;
     Timer.Elapsed += new ElapsedEventHandler(delegate(object sender, ElapsedEventArgs e)
     {
         // TODO : Find alternative !!
         /*
         System.Windows.Application.Current.Dispatcher.BeginInvoke(
             new VoidDelegate(this.TimerElapsed));
          */
     });
     EnableRaisingEvents = true;
 }
Exemplo n.º 2
0
 public FileMonitor(IList<string> filePaths, FileChangedHandler fileChangeCallback)
 {
     _filePaths = filePaths;
     if(fileChangeCallback != null)
     {
         FileChanged += fileChangeCallback;
     }
 }
Exemplo n.º 3
0
 public FileMonitor(string filePath, FileChangedHandler fileChangeCallback)
 {
     _filePaths = new List<string> { filePath };
     if(fileChangeCallback != null)
     {
         FileChanged += fileChangeCallback;
     }
 }
Exemplo n.º 4
0
        public FileWatcherSafe(FileChangedHandler watchHandler)
        {
            fsw = new FileSystemWatcher(CfgPath.DocDir);
            fsw.IncludeSubdirectories = true;
            fsw.Path = CfgPath.DocDir;
            fsw.EnableRaisingEvents = true;
            fsw.Renamed            += Fsw_Renamed;
            fsw.Created            += Fsw_Created;
            fsw.Deleted            += Fsw_Deleted;

            m_timer = new System.Threading.Timer(new TimerCallback(OnTimer),
                                                 null, TimeoutMillis, TimeoutMillis);
            fswHandler = watchHandler;
        }
 public FileWatcher(string filepath, FileChangedHandler handler)
     : base(System.IO.Path.GetDirectoryName(filepath), System.IO.Path.GetFileName(filepath))
 {
     FilePath = filepath;
     Handler = handler;
     NotifyFilter =
         NotifyFilters.FileName |
         NotifyFilters.Attributes |
         NotifyFilters.LastAccess |
         NotifyFilters.LastWrite |
         NotifyFilters.Security |
         NotifyFilters.Size;
     Changed += new FileSystemEventHandler(delegate(object sender, FileSystemEventArgs e) {
         Handler(FilePath);
     });
     EnableRaisingEvents = true;
 }
Exemplo n.º 6
0
 public FileWatcher(string filepath, FileChangedHandler handler) :
     base(System.IO.Path.GetDirectoryName(filepath), System.IO.Path.GetFileName(filepath))
 {
     FilePath     = filepath;
     Handler      = handler;
     NotifyFilter =
         NotifyFilters.FileName |
         NotifyFilters.Attributes |
         NotifyFilters.LastAccess |
         NotifyFilters.LastWrite |
         NotifyFilters.Security |
         NotifyFilters.Size;
     Changed += new FileSystemEventHandler(delegate(object sender, FileSystemEventArgs e) {
         Handler(FilePath);
     });
     EnableRaisingEvents = true;
 }