Problem description:
I have a document that is in word format, and the document extension is non doc/docx. I need to read the contents of the document through Spire.Doc.
My current solution is to change the extension of the document to Doc, and then read the contents of the operation, after the completion of the operation, and then expand the document back to non doc/docx.
But the performance of such a program is not good enough. Is there any other solution?
The original solution code is as follows:
问题描述:
我有一个文档,该文档为word格式,文档的拓展名为非doc/docx。我需要通过Spire.Doc读取文档的内容。
我目前的解决方案是将文档的拓展名改为doc,然后进行内容读取操作,操作完成后再将文档的拓展改回非doc/docx。
但是这样的方案运行性能不够好,有没有其它的解决方案呢?
原解决方案代码如下:
//修改文件拓展名为doc
//Modify the file extension to doc
string ext_old = "";
ext_old = Path.GetExtension(path_old);
string path_new = Path.ChangeExtension(path_old, ".doc");
File.Move(path_old, path_new);
//读取修改拓展名后的文件
//Read and modify the extension after the file
Document doc = new Document();
doc.LoadFromFile(path_new);
//修改文件拓展名非doc
//Modify file extensions to non doc
File.Move(path_new, path_old);