This documentation is archived and is not being maintained.

ResourceWriter.Close Method

Saves the resources to the output stream and then closes it.

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

public void Close()

Implements

IResourceWriter.Close()

ExceptionCondition
IOException

An I/O error has occurred.

SerializationException

An error has occurred during serialization of the object.

Generate is called implicitly by Close, if required.

The following code example uses the Close method to write all resource objects in a ResourceWriter class to the output stream. The code then shuts down the writer and makes the writer's resources available for other processes.


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", 
        FileMode.OpenOrCreate,FileAccess.Write);

        // 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.
        writer.Close();
    }
}


.NET Framework

Supported in: 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Show: