Free Support Forum - aspose.com

Opening txt and rtf file

Hi!

Is there a way to open rtf and txt files in Aspose.Word? I can open .doc files perfectly, but when I try with txt or rtf files, I get an error “That the file %1 already exists”. I’m using version 1.6 of Aspose.Word. Do I need to do something special?

Chris

Hi Chris,

Opening RTF and TXT files is not yet supported, but will be included in later versions. Not exactly sure when, but sometime in Augusut.

By the way, with a little programming you can open TXT files yourself, what you need:

1. Open a blank Word document to have a Document object.
2. Create DocumentBuilder and attach to the Document.
3. Open a text file using .NET classes.
4. Read all lines from the text file in a loop and call DocumentBuilder.Writeln(line) method to add lines from the text file to the Document as paragraphs.
5. If you save the Document, you will get a DOC file now.