Convert DOC to DOCX in C#
DocToDocxConverter reads a Word 97-2003 .doc file and writes a modern .docx package. Text, tables and character formatting such as bold come through intact.
using DocToolkit;
byte[] doc = File.ReadAllBytes("input.doc");
byte[] docx = DocToDocxConverter.Convert(doc);
File.WriteAllBytes("output.docx", docx);What it needs
- No browser, headless or otherwise.
- No Office install, and no LibreOffice.
- No native files: managed code only.
- No network at runtime, unless you ask for it.
Good to know
- Synchronous:
DocToDocxConverter.Converttakes the.docas abyte[]and returns the.docxas abyte[]. - It refuses a
.docholding pictures, drawings or form fields that a.docxcannot carry, rather than drop them quietly. SetLegacyDocOptions.AllowContentLossto accept the loss on purpose. ConvertWithReportreturns the same bytes and a list of what the import could not carry across.- Import only: it reads
.docand never writes one.