public PathModel(string path, IASContext context) { Owner = context; Path = path.TrimEnd(new char[] { '\\', '/' }); Files = new Dictionary<string, FileModel>(); LastAccess = DateTime.Now; updater = new Timer(); updater.Interval = 2000; updater.Tick += new EventHandler(updater_Tick); toExplore = new List<string>(); toRemove = new List<string>(); // generic models container if (context == null) { IsValid = true; } // watched path else if (Directory.Exists(Path) && Path.Length > 3) { IsValid = true; if (Owner != null) { try { watcher = new FileSystemWatcher(); watcher.Path = System.IO.Path.GetDirectoryName(Path); basePath = path; masks = Owner.GetExplorerMask(); watcher.IncludeSubdirectories = true; watcher.NotifyFilter = NotifyFilters.FileName | NotifyFilters.LastWrite | NotifyFilters.DirectoryName | NotifyFilters.Size; watcher.Deleted += new FileSystemEventHandler(watcher_Deleted); watcher.Changed += new FileSystemEventHandler(watcher_Changed); watcher.Renamed += new RenamedEventHandler(watcher_Renamed); watcher.EnableRaisingEvents = true; watcher.InternalBufferSize = 4096 * 8; } catch { watcher = null; IsValid = false; } } } else if (File.Exists(Path) && Owner != null) { IsValid = true; IsVirtual = true; try { watcher = new FileSystemWatcher(); basePath = watcher.Path = System.IO.Path.GetDirectoryName(Path); masks = new string[] { System.IO.Path.GetFileName(path) }; watcher.IncludeSubdirectories = false; watcher.NotifyFilter = NotifyFilters.FileName | NotifyFilters.LastWrite | NotifyFilters.DirectoryName | NotifyFilters.Size; watcher.Deleted += new FileSystemEventHandler(watcher_Deleted); watcher.Changed += new FileSystemEventHandler(watcher_Changed); watcher.Renamed += new RenamedEventHandler(watcher_Renamed); watcher.EnableRaisingEvents = true; } catch { watcher = null; IsValid = false; } } }