将docx,doc转换为使用open xml sdk 2.0打开xml在转换doc时它与docx一起正常工作它的错误该文件已损坏数据

时间:2014-05-24 05:15:04

标签: c# using openxml-sdk doc

if(fileExt ==“。doc”|| fileExt ==“。dococ”)          {           使用(WordprocessingDocument wordDoc = WordprocessingDocument.Open(document,true))              {                  string docText = null;              使用(StreamReader sr = newStreamReader(wordDoc.MainDocumentPart.GetStream()))                  {                      docText = sr.ReadToEnd();                      lbtext.Text = docText;                  }
             }
          }

1 个答案:

答案 0 :(得分:0)

您正在尝试使用SDK为新格式打开旧的(2003?)格式文件...

解决方案是在尝试打开文件之前将文件转换为新格式。 “WordConv.exe”是你的朋友......