New to Telerik UI for WinFormsStart a free 30-day trial

Using TxtFormatProvider

Updated on May 7, 2026

TxtFormatProvider makes it easy to import and export RadDocument to/from plain text format, preserving the document structure.

To use TxtFormatProvider, you should reference the Telerik.WinControls.RichTextEditor.dll and add the following namespace:

  • Telerik.WinForms.Documents.FormatProviders.Txt

Import

In order to import a plain text document, you need to use the Import() method of TxtFormatProvider. The first example shows how to use TxtFormatProvider to import a document from a file.

Import Document from a File

C#
TxtFormatProvider provider = new TxtFormatProvider();
using (Stream input = File.OpenRead(@"..\..\RichTextEditor\ImportExport\Sample.txt"))
{
    this.radRichTextEditor1.Document = provider.Import(input);
}

And here is how you can import a document from string:

Import Document from a String

C#
TxtFormatProvider provider = new TxtFormatProvider();
this.radRichTextEditor1.Document = provider.Import(input);

The resulting RadDocument can be manipulated like any code-generated document.

Export

In order to export a document to plain text, you need to use the Export() method of TxtFormatProvider.

This example shows how to use TxtFormatProvider to export RadDocument to a file.

Export a Document to a File

C#
TxtFormatProvider provider = new TxtFormatProvider();
using (Stream output = File.OpenWrite("sample.txt"))
{
    RadDocument document = this.radRichTextEditor1.Document;
    provider.Export(document, output);
}

You can also export the document to a string and preserve it in a database.

Export a Document to a String

C#
TxtFormatProvider provider = new TxtFormatProvider();
RadDocument document = this.radRichTextEditor1.Document;
string output = provider.Export(document);

See Also

In this article
ImportExportSee Also
Not finding the help you need?
Contact Support