Export (0) Print
Expand All

ResXResourceWriter Class

Writes resources in an XML resource (.resx) file or an output stream.

System.Object
  System.Resources.ResXResourceWriter

Namespace:  System.Resources
Assembly:  System.Windows.Forms (in System.Windows.Forms.dll)

[PermissionSetAttribute(SecurityAction.InheritanceDemand, Name = "FullTrust")]
[PermissionSetAttribute(SecurityAction.LinkDemand, Name = "FullTrust")]
public class ResXResourceWriter : IResourceWriter, 
	IDisposable

The ResXResourceWriter type exposes the following members.

  NameDescription
Public methodResXResourceWriter(Stream)Initializes a new instance of the ResXResourceWriter class that writes the resources to the specified stream object.
Public methodResXResourceWriter(String)Initializes a new instance of the ResXResourceWriter class that writes the resources to the specified file.
Public methodResXResourceWriter(TextWriter)Initializes a new instance of the ResXResourceWriter class that writes to the specified TextWriter object.
Public methodResXResourceWriter(Stream, Func<Type, String>)Initializes a new instance of the ResXResourceWriter class that writes the resources to a specified stream object and sets a converter delegate. This delegate enables resource assemblies to be written that target versions of the .NET Framework before the .NET Framework 4 by using qualified assembly names. 
Public methodResXResourceWriter(String, Func<Type, String>)Initializes a new instance of the ResXResourceWriter class that writes the resources to a specified file and sets a delegate that enables resource assemblies to be written that target versions of the .NET Framework before the .NET Framework 4 by using qualified assembly names. 
Public methodResXResourceWriter(TextWriter, Func<Type, String>)Initializes a new instance of the ResXResourceWriter class that writes the resources to a specified TextWriter object and sets a delegate that enables resource assemblies to be written that target versions of the .NET Framework before the .NET Framework 4 by using qualified assembly names.
Top

  NameDescription
Public propertyBasePathGets or sets the base path for the relative file path specified in a ResXFileRef object.
Top

  NameDescription
Public methodAddAliasAdds the specified alias to a list of aliases.
Public methodAddMetadata(String, Byte[])Adds a design-time property whose value is specifed as a byte array to the list of resources to write.
Public methodAddMetadata(String, Object)Adds a design-time property whose value is specified as an object to the list of resources to write.
Public methodAddMetadata(String, String)Adds a design-time property whose value is specified as a string to the list of resources to write.
Public methodAddResource(ResXDataNode)Adds a named resource specified in a ResXDataNode object to the list of resources to write.
Public methodAddResource(String, Byte[])Adds a named resource specified as a byte array to the list of resources to write.
Public methodAddResource(String, Object)Adds a named resource specified as an object to the list of resources to write.
Public methodAddResource(String, String)Adds a string resource to the resources.
Public methodCloseReleases all resources used by the ResXResourceWriter.
Public methodDispose()Releases all resources used by the ResXResourceWriter.
Protected methodDispose(Boolean)Releases the unmanaged resources used by the ResXResourceWriter and optionally releases the managed resources.
Public methodEquals(Object)Determines whether the specified object is equal to the current object. (Inherited from Object.)
Protected methodFinalizeThis member overrides the Finalize method. (Overrides Object.Finalize().)
Public methodGenerateWrites all resources added by the AddResource method to the output file or stream.
Public methodGetHashCodeServes as the default hash function. (Inherited from Object.)
Public methodGetTypeGets the Type of the current instance. (Inherited from Object.)
Protected methodMemberwiseCloneCreates a shallow copy of the current Object. (Inherited from Object.)
Public methodToStringReturns a string that represents the current object. (Inherited from Object.)
Top

  NameDescription
Public fieldStatic memberBinSerializedObjectMimeTypeInfrastructure. Specifies the default content type for a binary object. This field is read-only.
Public fieldStatic memberByteArraySerializedObjectMimeTypeInfrastructure. Specifies the default content type for a byte array object. This field is read-only.
Public fieldStatic memberDefaultSerializedObjectMimeTypeInfrastructure. Specifies the default content type for an object. This field is read-only.
Public fieldStatic memberResMimeTypeInfrastructure. Specifies the content type of an XML resource. This field is read-only.
Public fieldStatic memberResourceSchemaInfrastructure. Specifies the schema to use in writing the XML file. This field is read-only.
Public fieldStatic memberSoapSerializedObjectMimeTypeInfrastructure. Specifies the content type for a SOAP object. This field is read-only.
Public fieldStatic memberVersionSpecifies the version of the schema that the XML output conforms to. This field is read-only.
Top

The ResXResourceWriter writes resources in XML format. To write a binary resource file, use ResourceWriter.

Resources are specified as name/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, ResXResourceWriter does not allow a.resx file to have names that vary only by case.

To create a.resx file, create a ResXResourceWriter 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 Generate the file if required.

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

For more information on the format of a.resx file, see Working with .resx Files Programmatically.

NoteNote

This class contains a link demand and an inheritance demand at the class level that applies to all members. A SecurityException is thrown when either the immediate caller or the derived class does not have full-trust permission. For details about security demands, see Link Demands and Inheritance Demands.

.NET Framework

Supported in: 4.5.2, 4.5.1, 4.5, 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

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

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