If you are using the Aspose library as stated in your comment you can achieve this through a customised implementation of the IReplacingCallback interface.
bool IsContain(string word, string filePath)
{
Document doc = new Document(filePath);
OccurrencesCounter counter = new OccurrencesCounter();
doc.Range.Replace(new Regex(word), counter, false);
return counter.Occurrences > 0;
}
private class OccurrencesCounter : IReplacingCallback
{
public ReplaceAction Replacing(ReplacingArgs args)
{
mOccurrences++;
return ReplaceAction.Skip;
}
public int Occurrences
{
get { return mOccurrences; }
}
private int mOccurrences;
}
0
solved How to search a given word in word file by C# [closed]