System.Resources.ResourceWriter Class

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

See Also: ResourceWriter Members


public sealed class ResourceWriter : IResourceWriter


System.Resources.ResourceWriter provides a default implementation of the System.Resources.IResourceWriter interface. It enables you to programmatically create a binary resource (.resources) file.

Resources are specified as name and value pairs using the ResourceWriter.AddResource(string, string) method. Resource names are case-sensitive when used for lookups, but to more easily support authoring tools and help eliminate bugs, System.Resources.ResourceWriter will not allow a .resources file to have names that vary only by case. The System.Resources.ResourceWriter class enables you to create string, object, and binary resources. Binary resources can be written to the resource file as a byte array or a stream.

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

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

To retrieve resources from a binary .resources file created by the System.Resources.ResourceWriter class, you can use the System.Resources.ResourceManager class, which lets you retrieve named resources, or the System.Resources.ResourceReader class, which lets you enumerate all the resources in the file.


Namespace: System.Resources
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: 1.0.5000.0,,