# Export and Import

## Content

[C1Editor](/componentone/api/win/online-editor-net/dotnet-api/C1.Win.Editor.10/C1.Win.Editor.C1Editor.html) supports loading and saving DOCX and RTF documents in addition to HTML, HTM, and plain text formats.
This support allows applications to open, edit, and save DOCX and RTF content directly in `C1Editor` using the same document APIs already used for other supported formats. The functionality is available across supported .NET Framework and modern .NET WinForms applications.
**Dependencies**
DOCX and RTF support relies on the following dependency.

* `C1.Word`

***

**Supported Features**
`C1Editor` supports:

* Loading DOCX and RTF documents from file paths
* Loading DOCX and RTF documents from streams
* Opening DOCX and RTF documents through file dialogs
* Saving editor content to DOCX and RTF file paths
* Saving editor content to streams
* Saving documents through file dialogs

This support extends the existing document workflow and does not change HTML, HTM, or plain text behavior.

***

## Supported APIs

The following APIs support DOCX and RTF document loading and saving.

| API Name | Parameters | @cols=2:Description |
| -------- | ---------- | ----------- | ----------- |
| `LoadDocumentAsync()` | `string str, StringType strType = StringType.Url` | Loads a document from the specified file path without displaying a file dialog. Supports DOCX and RTF formats. |
| `LoadDocumentAsync()` | `Stream stream, bool leaveOpen = false` | Loads a document from the specified stream without displaying a file dialog. Supports DOCX and RTF formats. |
| `LoadDocumentRequestAsync()` | `string defaultFolder = "", bool restoreFolder = false` | Displays the Open File dialog and loads the selected DOCX or RTF document. |
| `SaveDocumentAsync()` | `string filename` | Saves the current document to the specified file path without displaying a file dialog. Supports DOCX and RTF formats. |
| `SaveDocumentAsync()` | `Stream stream, bool leaveOpen = false` | Saves the current document to the specified stream without displaying a file dialog. Supports DOCX and RTF formats. |
| `SaveDocumentRequestAsync()` | `string defaultFolder = "", bool restoreFolder = false` | Displays the Save File dialog and saves the current document in the selected format. |

***

## Format Handling

DOCX and RTF support uses the existing document-loading and document-saving APIs rather than separate format-specific methods.
When loading, the format is determined by the input document. When saving, the format is determined by the output file or selected format.

***

### Import Documents

Applications can load DOCX and RTF documents directly from a file path.

```csharp
await c1Editor1.LoadDocumentAsync(filePath);
```

Applications can also load documents from a stream.

```csharp
using FileStream stream = File.OpenRead(filePath);
await c1Editor1.LoadDocumentAsync(stream);
```

When user-driven file selection is required, applications can use the file dialog API.

```csharp
await c1Editor1.LoadDocumentRequestAsync();
```

![C1WinForms Editor - Importing docx and rtf file](https://cdn.mescius.io/document-site-files/images/c8989ae3-804c-4f29-b5ce-fe6b13c0a9e3/image-20261008.84ba8b.png?width=250&verticalAlign=middle)

***

### Export Documents

Applications can save editor content directly to a file path.

```csharp
await c1Editor1.SaveDocumentAsync(filePath);
```

Applications can also save content to a stream.

```csharp
using MemoryStream stream = new();

await c1Editor1.SaveDocumentAsync(stream);

byte[] documentData = stream.ToArray();
```

When user-driven file selection is required, applications can use the save file dialog API.

```csharp
await c1Editor1.SaveDocumentRequestAsync();
```

![C1WinForms Editor - Exporting docx and rtf file](https://cdn.mescius.io/document-site-files/images/c8989ae3-804c-4f29-b5ce-fe6b13c0a9e3/image-20261008.eab83b.png?width=600&verticalAlign=middle)

***

## Limitations

| Limitation | @cols=2:Description |
| ---------- | ----------- | ----------- |
| `C1.Word` dependency | Supported content and formatting depend on the capabilities of `C1.Word` |
| Format conversion differences | Some formatting or document features may not be preserved exactly during conversion |

***

## Sample Code

The following example demonstrates loading and saving DOCX and RTF documents through file paths, streams, and file dialogs.

```csharp
public partial class EditorDocxRtfSample : UserControl
{
    private readonly string _resourcesFolder =
        Path.Combine(
            AppContext.BaseDirectory,
            "Resources");

    public EditorDocxRtfSample()
    {
        InitializeComponent();
    }

    private async void btnLoadDocx_Click(
        object sender,
        EventArgs e)
    {
        string filePath =
            Path.Combine(_resourcesFolder, "Sample.docx");

        await c1Editor1.LoadDocumentAsync(filePath);
    }

    private async void btnLoadRtf_Click(
        object sender,
        EventArgs e)
    {
        string filePath =
            Path.Combine(_resourcesFolder, "Sample.rtf");

        await c1Editor1.LoadDocumentAsync(filePath);
    }

    private async void btnSaveDocx_Click(
        object sender,
        EventArgs e)
    {
        string filePath =
            Path.Combine(
                Environment.GetFolderPath(
                    Environment.SpecialFolder.MyDocuments),
                "Sample.docx");

        await c1Editor1.SaveDocumentAsync(filePath);
    }

    private async void btnSaveRtf_Click(
        object sender,
        EventArgs e)
    {
        string filePath =
            Path.Combine(
                Environment.GetFolderPath(
                    Environment.SpecialFolder.MyDocuments),
                "Sample.rtf");

        await c1Editor1.SaveDocumentAsync(filePath);
    }

    private async void btnLoadFromStream_Click(
        object sender,
        EventArgs e)
    {
        string filePath =
            Path.Combine(_resourcesFolder, "Sample.docx");

        using FileStream stream = File.OpenRead(filePath);

        await c1Editor1.LoadDocumentAsync(stream);
    }

    private async void btnSaveToStream_Click(
        object sender,
        EventArgs e)
    {
        using MemoryStream stream = new();

        await c1Editor1.SaveDocumentAsync(stream);

        byte[] documentData = stream.ToArray();
    }

    private async void btnOpen_Click(
        object sender,
        EventArgs e)
    {
        await c1Editor1.LoadDocumentRequestAsync();
    }

    private async void btnSaveAs_Click(
        object sender,
        EventArgs e)
    {
        await c1Editor1.SaveDocumentRequestAsync();
    }
}
```