Search code examples
c#ms-wordms-officeoffice-interop

How to programmatically detect if the word(2003) document is corrupted?


Possible Duplicate:
How to programatically tell if a word document is corrupt?

I want to check if word(.doc binary format) document is corrupted using c#. I'am generate PDF and html from existing doc files using Interop.Word and want to detect and isolate corrupted doc files for manually processing. Interop.Word do not generate any exception or event if file is corrupted it just show a dialog box for choosing right encoding. I suppress all dialogs using flag "DisplayAlerts = Word.WdAlertLevel.wdAlertsNone" because where's stop process execution. Any ideas?


Solution

  • Read the Word document as described here. You should get an exception if the document is corrupted. (also take a look at the question posted in the comment below your question)