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
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback


Trusted by the world’s leading companies

Syncfusion Trusted 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

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon