开发者

How to check whether given file is in PROPER word file format?

I am developing one application using 开发者_Python百科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


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!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜