FileIndexing
EventHub.FileIndexing event
Occurs when a document is going to be indexed.
public event EventHandler<FileIndexingEventArgs> FileIndexing;
Examples
The example demonstrates how to use the event.
string indexFolder = @"c:\MyIndex\";
string documentsFolder = @"c:\MyDocuments\";
// Creating an index
Index index = new Index(indexFolder);
// Subscribing to the event
index.Events.FileIndexing += (sender, args) =>
{
if (args.DocumentFullPath.EndsWith("Protected.pdf", StringComparison.InvariantCultureIgnoreCase))
{
args.AdditionalFields = new DocumentField[]
{
new DocumentField("Tags", "Protected")
};
}
if (!args.DocumentFullPath.ToLowerInvariant().Contains("important"))
{
args.SkipIndexing = true;
}
};
// Indexing documents from the specified folder
index.Add(documentsFolder);
See Also
- class FileIndexingEventArgs
- class EventHub
- namespace GroupDocs.Search.Events
- assembly GroupDocs.Search