Effortlessly convert Word documents to text files and vice versa with a few lines of C# code, without Microsoft Word or interop dependencies, using the powerful Syncfusion .NET Word Library (DocIO).
Here is an example of how to convert a Word document to a text file in C# using the Syncfusion .NET Word Library (DocIO).
//Load an existing Word document.
using FileStream inputStream = new FileStream("Template.docx", FileMode.Open, FileAccess.Read);
using WordDocument document = new WordDocument(inputStream, FormatType.Docx);
//Save the Word document as a text file.
using FileStream outputStream = new FileStream("Sample.txt", FileMode.Create, FileAccess.Write);
document.Save(outputStream, FormatType.Txt);
Here is an example of how to convert a text file to a Word document in C# using the Syncfusion .NET Word Library (DocIO).
//Load an existing text document.
using FileStream inputStream = new FileStream("Template.txt", FileMode.Open, FileAccess.Read);
using WordDocument document = new WordDocument(inputStream, FormatType.Txt);
//Save the Word document.
using FileStream outputStream = new FileStream("Sample.docx", FileMode.Create, FileAccess.Write);
document.Save(outputStream, FormatType.Docx);
Greatness—it’s one thing to say you have it, but it means more when others recognize it. Syncfusion is proud to hold the following industry awards.