Когда я пытаюсь прочитать файл .doc с помощью dll DocumentFormat.OpenXml, выдается ошибка: «Файл содержит поврежденные данные».
Эта dll правильно читает файл .docx.
Может ли dll DocumentFormat.OpenXml помочь в чтении файла .doc?
string path = @"D:\Data\Test.doc";
string searchKeyWord = @"java";
private bool SearchWordIsMatched(string path, string searchKeyWord)
{
try
{
using (WordprocessingDocument wordDoc = WordprocessingDocument.Open(path, true))
{
var text = wordDoc.MainDocumentPart.Document.InnerText;
if (text.Contains(searchKeyWord))
return true;
else
return false;
}
}
catch (Exception ex)
{
throw ex;
}
}