Click here to Skip to main content
15,887,477 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
while opening the word file using below code i'm getting the subject message

C#
using (WordprocessingDocument wordDoc = WordprocessingDocument.Open(StrDes,true))
            {



After i've tried reading the file through package like this. i got same error again

C#
Package package = Package.Open(StrDes, FileMode.Open, FileAccess.ReadWrite);
            WordprocessingDocument wordDoc = WordprocessingDocument.Open(package);


What I have tried:

C#
while opening the word file using below code i'm getting the subject message 

<pre lang="C#">using (WordprocessingDocument wordDoc = WordprocessingDocument.Open(StrDes,true))
            {</pre>


After i've tried reading the file through package like this. i got same error again

<pre lang="C#">Package package = Package.Open(StrDes, FileMode.Open, FileAccess.ReadWrite);
            WordprocessingDocument wordDoc = WordprocessingDocument.Open(package);</pre>
Posted
Updated 15-Oct-16 22:59pm
Comments
Richard MacCutchan 16-Oct-16 4:43am    
The message is quite clear, something is missing or invalid. What that something may be is anyone's guess.

1 solution

Start by looking at your data file: is it a Word document at all? Is it a version of Word that the WordprocessingDocument class understands? Or is it a pre-XML format (which were generally binary rather than "human readable"?

I'd guess that you'll find an older binary format in there, in which case you'll probably need Word interop to read it.
 
Share this answer
 
Comments
rajah rajah 17-Oct-16 1:36am    
My requirement it that i should not use interop, which needs MS office to be installed. So when i try some opensource. i found OpenXML.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900