public LibraryWatcherService()
 {
     InitializeComponent();
     if (!Config.isValidSettingValue("LIBRARY_NAME")) {
         string message = "The library name is not set in the configuration file";
         eventLog.WriteEntry(message, EventLogEntryType.Error);
         throw new Exception(message);
     }
     if (!Config.isValidSettingValue("DEST_FILE")) {
         string message = "The destination file is not set in the configuration file";
         eventLog.WriteEntry(message, EventLogEntryType.Error);
         throw new Exception(message);
     }
     string name = Properties.Settings.Default.LIBRARY_NAME;
     string destinationFile = Properties.Settings.Default.DEST_FILE;
     Library library = new Library(name, LibraryManager.getLibraryFolders(name));
     if (!library.isValid()) {
         string message = "Could not load the library: " + library.Name;
         eventLog.WriteEntry(message, EventLogEntryType.Error);
         throw new Exception(message);
     }
     LibraryFile db = new LibraryFile(library, destinationFile);
     db.init();
     watcher = new LibraryWatcher(library, db);
 }
 /// <summary>
 /// Creates a LibraryContents instance from the given library lib
 /// </summary>
 /// <param name="lib">Library</param>
 /// <returns>LibraryContents instance</returns>
 public static LibraryContents create(Library lib)
 {
     LibraryContents c = new LibraryContents();
     foreach (string s in lib.Folders) {
         c.addSubFolders(s);
     }
     c.sort();
     return c;
 }
 public LibraryFile(Library lib, string file)
 {
     library = lib;
     FILE = file;
     contents = new LibraryContents();
 }
 public LibraryWatcher(Library library, LibraryFile file)
 {
     this.library = library;
     libraryFile = file;
     watchers = new List<FileSystemWatcher>();
 }