Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

ResourceWriter Constructor (String)

Initializes a new instance of the ResourceWriter class that writes the resources to the specified file.

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

public ResourceWriter(
	string fileName
)

Parameters

fileName
Type: System.String

The output file name.

ExceptionCondition
ArgumentNullException

The fileName parameter is null.

The following code example defines a new instance of the ResourceWriter class that will write to a specified file. The code adds resources to the writer and writes the resources to the 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();
   }
}

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0, 2.0, 1.1

.NET Framework Client Profile

Supported in: 4, 3.5 SP1
Show:
© 2015 Microsoft