tags:

views:

26

answers:

1

Hi, I am developing one application using C# for processing MSWord files. My application gets hang when I pass invalid .doc file as an input. For example, if I have one foo.pdf file and I pass it to my application after changing its extension (foo.doc). Is it possible to check whether file is valid doc file before trying to open it? Please enlighten !!!!

Thanks in advance

+1  A: 

Hello,

If you are using Office PIA to process the word files you could first get the metadata information of the document. If it returns some metadata it should be a valid word document.

Refer the following for reading metadata in word documents: http://bytes.com/topic/c-sharp/answers/757466-c-app-reading-modifying-ms-office-document-meta-data

Hope that would be quicker then processing the whole invalid document.

Hope it helps!

Vaibhav
Thanks a lot Vaibhav.
Shekhar