internal bool StartInstance(WatcherFolderOption option, WatcherFactory factory) { Options = option; GUID = option.FolderGUID; //snapshotFactory = new SnapshotFactory(backupPath); return(InitInstance(factory)); }
//public SnapshotFactory snapshotFactory { get; set; } private bool InitInstance(WatcherFactory watcherFactory) { try { Factory = watcherFactory; Watcher = new FileSystemWatcher(); Watcher.InternalBufferSize = Options.InternalBufferSize < 4096 ? 8192 : Options.InternalBufferSize; Watcher.NotifyFilter = NotifyFilters.LastAccess | NotifyFilters.LastWrite | NotifyFilters.FileName | NotifyFilters.DirectoryName; Watcher.Filter = Options.FolderFilter; Watcher.Path = Options.FolderPath; Watcher.IncludeSubdirectories = Options.FolderIncludeSub; Watcher.Changed += new FileSystemEventHandler(OnChanged); Watcher.Created += new FileSystemEventHandler(OnCreated); Watcher.Deleted += new FileSystemEventHandler(OnDeleted); Watcher.Renamed += new RenamedEventHandler(OnRenamed); Watcher.Error += new ErrorEventHandler(OnError); Watcher.EnableRaisingEvents = Options.FolderEnabled; Listening = Options.FolderEnabled; slLogger.WriteLogLine("FileShadowWatcher now listening on Directory " + Options.FolderPath); } catch (Exception ex) { slLogger.WriteLogLine(ex); return(false); } return(true); }
//-1 = no Options 0=Everythings fine 1=Error internal bool StartInstance(WatcherFactory factory) { return(InitInstance(factory)); }