How to convert a Word DOC 97–03 Document to Text TXT in C# .NET Framework

Working with older file types can be very inconvenient. That’s why today’s lesson is on how to convert legacy DOC files from old versions of Microsoft Word into more useful TXT files.

Our client installation needs to come first on our list. That just means activating this command in your Package Manager console.

Install-Package Cloudmersive.APIClient.NET.DocumentAndDataConvert -Version 2.2.0

Alright, now we just have to call ConvertDocumentDocToTxt and give it our DOC file.

using System;using System.Diagnostics;using Cloudmersive.APIClient.NET.DocumentAndDataConvert.Api;using Cloudmersive.APIClient.NET.DocumentAndDataConvert.Client;using Cloudmersive.APIClient.NET.DocumentAndDataConvert.Model;namespace Example{public class ConvertDocumentDocToTxtExample{public void main(){// Configure API key authorization: ApikeyConfiguration.Default.AddApiKey("Apikey", "YOUR_API_KEY");// Uncomment below to setup prefix (e.g. Bearer) for API key, if needed// Configuration.Default.AddApiKeyPrefix("Apikey", "Bearer");var apiInstance = new ConvertDocumentApi();var inputFile = new System.IO.Stream(); // System.IO.Stream | Input file to perform the operation on.try{// Convert Word DOC (97-03) Document to Text (txt)TextConversionResult result = apiInstance.ConvertDocumentDocToTxt(inputFile);Debug.WriteLine(result);}catch (Exception e){Debug.Print("Exception when calling ConvertDocumentApi.ConvertDocumentDocToTxt: " + e.Message );}}}}

And that’s all there is to it. Seriously, you’re done. For all your API needs, check out the rest of this tutorial series.

Image for post

There’s an API for that. Cloudmersive is a leader in Highly Scalable Cloud APIs.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store