public static void MakeSearchIndex () { // Loads the RootTree Console.WriteLine ("Loading the monodoc tree..."); RootTree root = LoadTree (); if (root == null) return; string dir = Path.Combine (root.basedir, "search_index"); IndexWriter writer; //try to create the dir to store the index try { if (!Directory.Exists (dir)) Directory.CreateDirectory (dir); writer = new IndexWriter(Lucene.Net.Store.FSDirectory.GetDirectory(dir, true), new StandardAnalyzer(), true); } catch (UnauthorizedAccessException) { //try in the .config directory try { dir = Path.Combine (SettingsHandler.Path, "search_index"); if (!Directory.Exists (dir)) Directory.CreateDirectory (dir); writer = new IndexWriter(Lucene.Net.Store.FSDirectory.GetDirectory(dir, true), new StandardAnalyzer(), true); } catch (UnauthorizedAccessException) { Console.WriteLine ("You don't have permissions to write on " + dir); return; } } //Collect all the documents Console.WriteLine ("Collecting and adding documents..."); foreach (HelpSource hs in root.HelpSources) hs.PopulateSearchableIndex (writer); //Optimize and close Console.WriteLine ("Closing..."); writer.Optimize(); writer.Close(); }