Effortlessly convert Word documents to text files and vice versa with a few lines of C# code. Neither Microsoft Word nor interop dependencies are required when using the powerful Syncfusion .NET Word Library (DocIO).
This example code shows how to convert a Word document into a text file using the Syncfusion .NET Word Library with just few lines of code in C#.
- using Syncfusion.DocIO;
- using Syncfusion.DocIO.DLS;
- //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("Result.txt", FileMode.Create, FileAccess.Write);
- document.Save(outputStream, FormatType.Txt);
Explore these resources for comprehensive guides, knowledge base articles, insightful blogs, and ebooks.
Product Updates
Technical Support
Yes, the Library supports Word file formats such as DOC, DOT, DOCX, DOTX, DOCM, DOTM, Word Processing 2007 XML, and RTF. Additionally, it can convert text into Markdown and HTML formats and vice versa.
Yes, the .NET Word Library supports retrieving the entire content of a Word document as a string without saving it as a text file.
Yes, the .NET Word Library supports batch conversion processes for text files to Word documents and vice versa.
Yes, you can convert text files to PDF and image formats using the .NET Word Library.
Yes, you can read the text file and insert it into a specific paragraph within a Word document programmatically.
You can access it through the Syncfusion.DocIO.Net.Core NuGet package. Detailed code samples are available in the documentation.
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.