ResXResourceReader Class
Assembly: System.Windows.Forms (in system.windows.forms.dll)
'Declaration Public Class ResXResourceReader Implements IResourceReader, IEnumerable, IDisposable 'Usage Dim instance As ResXResourceReader
public class ResXResourceReader implements IResourceReader, IEnumerable, IDisposable
public class ResXResourceReader implements IResourceReader, IEnumerable, IDisposable
Not applicable.
The ResXResourceReader provides a default implementation of the IResourceReader interface that reads resource information in an XML format. To read resource information from a binary resource format, use ResourceReader.
You can use resource readers to read resource name and value pairs from .resx files. The resources can be enumerated by traversing the IDictionaryEnumerator returned by the GetEnumerator method. You can use the methods provided by the IDictionaryEnumerator to advance to the next resource and read the name and value of each resource in the .resx file.
For more information on the format of a .resx file, see Resources in .Resx File Format.
Note: |
|---|
| IEnumerable.GetEnumerator returns an IEnumerator not IDictionaryEnumerator. |
Note: |
|---|
| 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. |
The following example demonstrates how to use a ResXResourceReader to iterate through the resources in a .resx file. First, the ResXResourceReaderrsxr is created for the file items.resx. Next, the GetEnumerator method is used to create an IDictionaryEnumerator to iterate through the resources and display the contents to the console.
Imports System Imports System.Resources Imports System.Collections Imports Microsoft.VisualBasic Class ReadResXResources Public Shared Sub Main() ' Create a ResXResourceReader for the file items.resx. Dim rsxr As ResXResourceReader rsxr = New ResXResourceReader("items.resx") ' Create an IDictionaryEnumerator to iterate through the resources. Dim id As IDictionaryEnumerator = rsxr.GetEnumerator() ' Iterate through the resources and display the contents to the console. Dim d As DictionaryEntry For Each d In rsxr Console.WriteLine(d.Key.ToString() + ":" + ControlChars.Tab + d.Value.ToString()) Next d 'Close the reader. rsxr.Close() End Sub End Class
- SecurityAction.LinkDemand for full trust for the immediate caller. This member cannot be used by partially trusted code.
- SecurityAction.InheritanceDemand for full trust for inheritors. This class cannot be inherited by partially trusted code.
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.Reference
ResXResourceReader MembersSystem.Resources Namespace
Note: