# Save and Load RDF Files

This topic explains how to save a report to a static RDF file and load it into the ActiveReports viewer.

## Content

ActiveReports allows reports to be saved in their own standard format called an RDF file (Report Document Format). In this format, the data is static. The saved report displays the data that is retrieved when you run the report. You can save a report to an RDF file and load it into the viewer control.

Section report can be stored as an RDF document using the [SectionDocument](/activereportsnet/api/v20.1/MESCIUS.ActiveReports/GrapeCity.ActiveReports.Document.SectionDocument.html) class. It is the intermediate format and can be used in following scenarios:

* to access data and parameters and export later as described in this topic
* to work with annotations, see [Add and Save Annotations](/activereportsnet/docs/v20.1/developers/working-with-reports-devs/section-report-developers/save-load-rdf-files/add-annotations).
* to merge reports, see [Insert or Add Report Pages](/activereportsnet/docs/v20.1/developers/working-with-reports-devs/section-report-developers/insert-or-add-pages).

## Save a report as a static RDF file

1. Double-click the title bar of the Windows Form to create an event-handling method for the Form\_Load event.
2. Add the following code to the handler to save the report.
<br>
    To write the code in Visual Basic.NET

    ```vbnet
    Dim rpt As New YourReportName()rpt.Run()
    rpt.Document.Save(Application.StartupPath + \NewRDF.RDF)
    ```

    To write the code in C#

    ```csharp
    YourReportName rpt = new YourReportName();rpt.Run();
    rpt.Document.Save(Application.StartupPath + \\NewRDF.RDF);
    ```

## Load a saved RDF file into the ActiveReports viewer

1. Double-click the title bar of the Windows Form to create an event-handling method for the Form\_Load event.
2. Add the following code to the handler to load the saved report.
<br>
    To write the code in Visual Basic.NET

    ```vbnet
    Viewer1.Document.Load("Location of the .RDF File")
    ```

    To write the code in C#

    ```csharp
    viewer1.Document.Load(@"Location of the .RDF File");
    ```

>type=note
> **Note**: The Windows Form Viewer can display RDF files made with any version of ActiveReports, including COM versions.

## Save or load report files to a memory stream

1. Double-click the title bar of the Windows Form to create an event-handling method for the Form\_Load event.
2. Add the following code to the handler to save the report to a memory stream and load the memory stream into the ActiveReports viewer.
<br>
    The following examples show what the code for the method looks like.
<br>
    To write the code in Visual Basic.NET

    ```vbnet
    Dim strm As New System.IO.MemoryStream()
    Dim rpt As New YourReportName()
    rpt.Run()
    rpt.Document.Save(strm)
    Dim theBytes(strm.Length) As Byte
    strm.Read(theBytes, 0, Int(strm.Length))
    strm.Position = 0
    Viewer1.Document.Load(strm)
    ```

    To write the code in C#

    ```csharp
    System.IO.MemoryStream strm = new System.IO.MemoryStream();
    YourReportName rpt = new YourReportName();
    rpt.Run();
    rpt.Document.Save(strm);
    byte[] theBytes = new byte[strm.Length];
    strm.Read(theBytes, 0, (int)strm.Length);
    strm.Position =0;
    viewer1.Document.Load(strm);
    ```

## See Also

#### Report Readers

[Windows Forms Viewer](/activereportsnet/docs/v20.1/report-readers/desktop-viewers/windows-forms-viewer)