public static void Run()
{
// ExStart:FindAndHighlight
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_FindAndReplace();
string fileName = "TestFile.doc";
Document doc = new Document(dataDir + fileName);
FindReplaceOptions options = new FindReplaceOptions();
options.ReplacingCallback = new ReplaceEvaluatorFindAndHighlight();
// We want the "your document" phrase to be highlighted.
Regex regex = new Regex("your document", RegexOptions.IgnoreCase);
doc.Range.Replace(regex, "", options);
dataDir = dataDir + RunExamples.GetOutputFilePath(fileName);
// Save the output document.
doc.Save(dataDir);
// ExEnd:FindAndHighlight
Console.WriteLine("\nText highlighted successfully.\nFile saved at " + dataDir);
}
// ExStart:ReplaceEvaluatorFindAndHighlight