How to determine whether two word documents are th

2019-07-17 03:43发布

Is there a good way to see if two documents are the same using the word interop?

I have tried using something like:

Word.Document tempDoc = app.CompareDocuments(document1, document2);

My issue is that tempDoc is not null if they are the same, so I'm not sure how to use this result to determine whether the documents are the same.

Thanks in advance!

1条回答
倾城 Initia
2楼-- · 2019-07-17 04:13

The document it returns is a document with track changes turned on. So all you have to do is see if there ARE any changes. So:

Document tempDoc = app.CompareDocuments(doc1, doc2);
bool anyChanges = tempDoc.Revisions.Count > 0;

See:

http://msdn.microsoft.com/en-us/library/microsoft.office.interop.word._application.comparedocuments.aspx

查看更多
登录 后发表回答