阅读Doc和Docx文件? 我可以使用什么dll来阅读doc和docx文件?
string path= @"D:\Resume02\test.doc";
private bool SearchWordIsMatched(string path, string searchKeyWord)
{
try
{
Microsoft.Office.Interop.Word.ApplicationClass wordApp = new ApplicationClass();
object file = path;
object nullobj = System.Reflection.Missing.Value;
object readOnly = true;
Microsoft.Office.Interop.Word.Document doc = wordApp.Documents.Open(
ref file, ref nullobj, ref readOnly,
ref nullobj, ref nullobj, ref nullobj,
ref nullobj, ref nullobj, ref nullobj,
ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj);
doc.ActiveWindow.Selection.WholeStory();
doc.ActiveWindow.Selection.Copy();
IDataObject data = Clipboard.GetDataObject();
string d = data.GetData(DataFormats.Text).ToString();
d.ToLower();
if (d.ToLower().Contains(searchKeyWord.ToLower()))
{
object doNotSaveChanges = Microsoft.Office.Interop.Word.WdSaveOptions.wdDoNotSaveChanges;
object originalFormat = Microsoft.Office.Interop.Word.WdOriginalFormat.wdWordDocument;
object routeDocument = true;
((_Document)doc).Close(ref doNotSaveChanges, ref originalFormat, ref routeDocument);
return true;
}
else
{
return false;
}
}
catch (System.Exception ex)
{
throw ex;
}
}