ResourceWriter Constructor (Stream)
Collapse the table of content
Expand the table of content

ResourceWriter Constructor (Stream)


Initializes a new instance of the ResourceWriter class that writes the resources to the provided stream.

Namespace:   System.Resources
Assembly:  mscorlib (in mscorlib.dll)

public ResourceWriter(
	Stream stream


Type: System.IO.Stream

The output stream.

Exception Condition

The stream parameter is not writable.


The stream parameter is null.

The following code example defines a new instance of the ResourceWriter class that writes to a specified stream. The code adds resources to the writer and writes the resources to the stream.

using System;
using System.Resources;
using System.IO;

public class WriteResources 
    public static void Main(string[] args) 
        // Create a file stream to encapsulate items.resources.
        FileStream fs = new FileStream("items.resources", 

        // Open a resource writer to write from the stream.
        IResourceWriter writer = new ResourceWriter(fs);

        // Add resources to the resource writer.
        writer.AddResource("String 1", "First String");
        writer.AddResource("String 2", "Second String");
        writer.AddResource("String 3", "Third String");

        // Write the resources to the stream, and close it.

Universal Windows Platform
Available since 10
.NET Framework
Available since 1.1
Return to top
© 2016 Microsoft