Delete

Delete(string[], UpdateOptions)

Deletes indexed files or folders from the index. Then updates the index without deleted paths. Note that an individual document cannot be deleted from the index if it was added to the index as part of a folder.

public DeleteResult Delete(string[] paths, UpdateOptions options)
Parameter Type Description
paths String[] The paths to files or folders to delete.
options UpdateOptions The update options.

Return Value

An object describing the result of deleting files or folders from the index.

Examples

The example demonstrates how to delete indexed paths from an index.

string indexFolder = @"c:\MyIndex\";
string documentsFolder1 = @"c:\MyDocuments\";
string documentsFolder2 = @"c:\MyDocuments2\";

// Creating an index in the specified folder
Index index = new Index(indexFolder);

// Indexing documents from the specified folders
index.Add(documentsFolder1);
index.Add(documentsFolder2);

// Getting indexed paths from the index
string[] indexedPaths1 = index.GetIndexedPaths();

// Writing indexed paths to the console
Console.WriteLine("Indexed paths:");
foreach (string path in indexedPaths1)
{
    Console.WriteLine("\t" + path);
}

// Deleting index path from the index
DeleteResult deleteResult = index.Delete(new string[] { documentsFolder1 }, new UpdateOptions());

// Getting indexed paths after deletion
string[] indexedPaths2 = index.GetIndexedPaths();
Console.WriteLine("\nDeleted paths: " + deleteResult.SuccessCount);

Console.WriteLine("\nIndexed paths:");
foreach (string path in indexedPaths2)
{
    Console.WriteLine("\t" + path);
}

See Also


Delete(UpdateOptions, string[])

Deletes documents indexed from streams or structures. Then updates the index without deleted documents.

public DeleteResult Delete(UpdateOptions options, string[] documentKeys)
Parameter Type Description
options UpdateOptions The update options.
documentKeys String[] The keys of documents added from streams or structures.

Return Value

An object describing the result of deleting documents from the index.

See Also