Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

ResourceWriter Class

Writes resources in the system-default format to an output file or an output stream. This class cannot be inherited.

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

[ComVisibleAttribute(true)] 
public sealed class ResourceWriter : IResourceWriter, IDisposable
/** @attribute ComVisibleAttribute(true) */ 
public final class ResourceWriter implements IResourceWriter, IDisposable
ComVisibleAttribute(true) 
public final class ResourceWriter implements IResourceWriter, IDisposable
Not applicable.

ResourceWriter provides a default implementation of the IResourceWriter interface.

Resources are specified as name and value pairs using the AddResource method. Resource names are case-sensitive when used for lookups, but to more easily support authoring tools and help eliminate bugs, ResourceWriter will not allow a .resources file to have names that vary only by case.

To create a resources file, create a ResourceWriter with a unique file name, call AddResource at least once, call Generate to write the resources file to disk, and then call Close to close the file. Calling Close will implicitly call Generate if you do not explicitly call Generate.

The resources will not necessarily be written in the same order they were added.

The following example writes several strings into the myResources.resources file.

using System;
using System.Resources;


public class WriteResources {
   public static void Main(string[] args) {
      
      // Creates a resource writer.
      IResourceWriter writer = new ResourceWriter("myResources.resources");
    
      // Adds resources to the resource writer.
      writer.AddResource("String 1", "First String");

      writer.AddResource("String 2", "Second String");

      writer.AddResource("String 3", "Third String");

      // Writes the resources to the file or stream, and closes it.
      writer.Close();
   }
}

import System.*;
import System.Resources.*;

public class WriteResources
{
    public static void main(String[] args)
    {
        // Creates a resource writer.
        IResourceWriter writer = new ResourceWriter("myResources.resources");

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

        // Writes the resources to the file or stream, and closes it.
        writer.Close();
    } //main
} //WriteResources

System.Object
  System.Resources.ResourceWriter

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Windows 98, Windows Server 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0, 1.1, 1.0

Community Additions

Show:
© 2014 Microsoft