How to programmatically determine if a text document is damaged?

I have a small C # application that has something in common with a word that converts a bunch of words .doc files into text files, and for the most part this works great.

However, if the document is current, then the word cannot open the file, and a dialog box appears, which means that I can not fully automate this conversion process - someone has to follow the dialog boxes.

Is there a way to check if the word .doc currupt is without opening it? Perhaps through the word interop, or perhaps through a third-party tool.

One of my ideas is to create a thread that performs the conversion and kill it if the process is open for longer than n seconds, but I was wondering if there was an easier way?

+3
source share
2 answers

The only reliable way to determine if Word will think the file is corrupt is to make Word open it :-). I don’t think that any third-party application will be 100% reliable in this regard - in the end, the document really cannot be damaged, but it will not help you if Word thinks this is so. However, it is obvious that there are some situations that you might find, for example, the file size is zero or the like.

(-?) , , , , , ? , - - ?

, Word . :

  • ( )
  • .

, Application.DisplayAlerts .., ( ).

, , Office, ( , ) . , . , , .

+3

, , Office . (. : http://support.microsoft.com/kb/257757)

Office 2007+, - OpenXML. , , , aspose API

0

Source: https://habr.com/ru/post/1709353/


All Articles