public SerializedDatabase(string serializationPath, bool watchForChanges) { if (!Path.IsPathRooted(serializationPath)) { serializationPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, serializationPath); } if (!Directory.Exists(serializationPath)) { throw new Exception(string.Format("Path not found {0}, current Path {1}", Path.GetFullPath(serializationPath), AppDomain.CurrentDomain.BaseDirectory)); } _index = new SerializedIndex(LoadItems(serializationPath)); _serializationPath = serializationPath; if (watchForChanges) { _watcher = new FileSystemWatcher(serializationPath, "*" + PathUtils.Extension) { IncludeSubdirectories = true }; _watcher.Changed += OnFileChanged; _watcher.Created += OnFileChanged; _watcher.Deleted += OnFileChanged; _watcher.Renamed += OnFileRenamed; _watcher.EnableRaisingEvents = true; } }
public SerializedDatabase(string serializationPath, bool watchForChanges) { if (!Path.IsPathRooted(serializationPath)) serializationPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, serializationPath); if (!Directory.Exists(serializationPath)) { throw new Exception(string.Format("Path not found {0}, current Path {1}", Path.GetFullPath(serializationPath), AppDomain.CurrentDomain.BaseDirectory)); } _index = new SerializedIndex(LoadItems(serializationPath)); _serializationPath = serializationPath; if (watchForChanges) { _watcher = new FileSystemWatcher(serializationPath, "*" + PathUtils.Extension) { IncludeSubdirectories = true }; _watcher.Changed += OnFileChanged; _watcher.Created += OnFileChanged; _watcher.Deleted += OnFileChanged; _watcher.Renamed += OnFileRenamed; _watcher.EnableRaisingEvents = true; } }