We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
Syncfusion Feedback


Trusted by the world’s leading companies

Overview

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).


How to convert a Word document to a text file in C#

  1. Install NuGet package: Install the Syncfusion.DocIO.Net.Core NuGet package in your project.
  2. Open Word document: Create a FileStream object to represent the input Word document.
  3. Load in .NET Word Library: Create a WordDocument object by passing the FileStream of the Word document.
  4. Convert Word file to text file: Save the WordDocument object as text file to a FileStream object.

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);

How to convert a text file to a Word document in C#

  1. Install NuGet package: Install the Syncfusion.DocIO.Net.Core NuGet package in your project.
  2. Open text file: Create a FileStream object to represent the input text file.
  3. Load in .NET Word Library: Create a WordDocument object by passing the FileStream of the text file.
  4. Convert text file to Word: Save the WordDocument object to a FileStream object.

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);



Awards

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.

Scroll up icon
Live Chat Icon For mobile
Live Chat Icon