简体   繁体   中英

converting docx,doc to open xml using open xml sdk 2.0 its working fine with docx when converting doc its error that file has corrupted data

if (fileExt == ".doc" || fileExt == ".docx") { using (WordprocessingDocument wordDoc = WordprocessingDocument.Open(document,true)) { string docText = null; using (StreamReader sr = newStreamReader(wordDoc.MainDocumentPart.GetStream())) { docText = sr.ReadToEnd(); lbtext.Text = docText; }
}
}

You're trying to open an old (2003?) format file using the SDK for the new format...

The solution is to convert the file into the new format before trying to open it. "WordConv.exe" is your friend...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM