Spire.Doc is a professional Word .NET library specifically designed for developers to create, read, write, convert and print Word document files. Get free and professional technical support for Spire.Doc for .NET, Java, Android, C++, Python.

Mon Nov 19, 2018 3:05 pm

Hello, does Spire.Doc have the functionality to convert a .doc file to a .docx? If so, could you provide sample code.

tholland
 
Posts: 23
Joined: Fri Dec 01, 2017 6:38 pm

Tue Nov 20, 2018 2:56 am

Hi tholland,

Thanks for your inquiry.
Please refer to below code:
Code: Select all
            //Load .doc file
            Document doc = new Document(@"F:\Sample.doc", FileFormat.Doc);
            //Save to .docx file
            doc.SaveToFile("result.docx", FileFormat.Docx);

If you still have the issue, please share your input Word file for further investigation.

Sincerely,
Betsy
E-iceblue support team
User avatar

Betsy.jiang
 
Posts: 3099
Joined: Tue Sep 06, 2016 8:30 am

Fri Nov 23, 2018 7:30 am

Hi tholland,

Greetings from E-iceblue.
Does the code I provided help you solve your issue? Could you please give us some feedback at your convenience?

Sincerely,
Betsy
E-iceblue support team
User avatar

Betsy.jiang
 
Posts: 3099
Joined: Tue Sep 06, 2016 8:30 am

Fri Dec 28, 2018 5:27 pm

Yes. Your solution was helpful. We really needed to convert a .doc sent in an http request and convert it to a .docx.

// Copy http file content as Memory Stream
MemoryStream ms = new MemoryStream();
httpRequest.Files[0].InputStream.CopyTo(ms);
// Load Document from a stream
Document document = new Document();
document.LoadFromStream(ms, FileFormat.Auto); //.doc
//Convert Doc to Docx
document.SaveToStream(ms, FileFormat.Docx);
document.LoadFromStream(ms, FileFormat.Docx);

tholland
 
Posts: 23
Joined: Fri Dec 01, 2017 6:38 pm

Sat Dec 29, 2018 2:05 am

Hi tholland,

Thanks for your feedback.
Please feel free to contact us if you need any help.
Wish you all the best!

Sincerely,
Betsy
E-iceblue support team
User avatar

Betsy.jiang
 
Posts: 3099
Joined: Tue Sep 06, 2016 8:30 am

Return to Spire.Doc