System.Resources.ResourceWriter.AddResourceData Method

Adds a unit of data as a resource to the list of resources to be written.

Syntax

public void AddResourceData (string name, string typeName, byte[] serializedData)

Parameters

name
A name that identifies the resource that contains the added data.
typeName
The type name of the added data. For more information, see the Remarks section.
serializedData
A byte array that contains the binary representation of the added data.

Remarks

Use the ResourceWriter.AddResourceData(string, string, Byte[]) method to add a resource in binary form (that is, as an array of bytes) to the list of resources to be written. You must specify the name of the resource, the type name of the data contained in the resource, and the binary representation of the data itself. After you have added each resource you require, use the ResourceWriter.Generate method to write the list of resources to the resources file or stream that was specified in the erload:System.Resources.ResourceWriter.#ctor constructor.

typeName is a string that represents the data type of the resource. It can be any of the following values:

  • The string representation of a ResourceTypeCode enumeration member that indicates the data type of the resource. ResourceTypeCode is a private enumeration that is used by Resgen.exe to indicate that a special binary format is used to store one of 19 common data types. These include the .NET Framework primitive data types (bool, byte, char, decimal, double, short, int, long, float, sbyte, ushort, uint, ulong), as well as string, DateTime, and TimeSpan. In addition, the ResourceTypeCode enumeration includes the values shown in the following table.

  • A string that contains the fully qualified name of the type whose binary data is assigned to the serializedData argument (for example, System.String). In addition, for types that are not part of the .NET Framework class library, the string includes the name, version, culture, and public key of the assembly that contains the type. For example, the following string indicates that the serialized data represents an instance of the Person type in the Extensions namespace, which is found in version 1.0 of an assembly named Utility that has no public key and no designated culture.

    Extensions.Person, Utility, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null

A parallel method for reading resource data written with the ResourceWriter.AddResourceData(string, string, Byte[]) method is ResourceReader.GetResourceData(string, String@, Byte[]@).

Requirements

Namespace: System.Resources
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: 2.0.0.0, 4.0.0.0
Since: .NET 2.0