用C#读取文档文件 [英] Read document file in C#
本文介绍了用C#读取文档文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我尝试使用WordprocessingDocument读取doc文件
但是收到错误喜欢
文件包含损坏的数据。
我的代码
string filepath = @\\ ... 116.27.DOC;
WordprocessingDocument wordprocessingDocument = WordprocessingDocument.Open(filepath,true); //错误行
Hi,
I am try to read doc file using WordprocessingDocument
But got an error like
File contains corrupted data.
My code
string filepath = @"\\...116.27.DOC";
WordprocessingDocument wordprocessingDocument = WordprocessingDocument.Open(filepath , true);//error line here
推荐答案
据我所知, WordprocessingDocument [ ^ ]仅用于处理新的.docx(openxml)格式。
我担心它是与旧的.doc(二进制)格式不兼容。这似乎是您的问题:您正在尝试打开此对象无法处理的文件格式。
您应该尝试将文档转换为。 docx one,并根据你的代码进行测试。
希望这会有所帮助。
As far as I know, WordprocessingDocument[^] is only made to handle new .docx (openxml) format.
I'm afraid it is not compatible with older .doc (binary) format. This seems to be your issue: you are trying to open a file format that this object is not able to handle.
You should try to convert your document to a .docx one, and test it against your code.
Hope this helps.
这篇关于用C#读取文档文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文