Khi tôi đang cố gắng đọc tệp .doc bằng cách sử dụng DocumentFormat.OpenXml dll, lỗi của nó là "Tệp chứa dữ liệu bị hỏng".Đọc .Doc Tệp bằng cách sử dụng DocumentFormat.OpenXml dll
Dll này đang đọc tệp .docx đúng cách.
Có thể DocumentFormat.OpenXml dll trợ giúp đọc tệp .doc không?
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;
}
}
Cám ơn câu trả lời của bạn. –
Có, tôi đang chờ đợi một số câu trả lời khác. –
Một năm trôi qua. Vẫn đang đợi. :/ –