This documentation is archived and is not being maintained.

ResourceManager.GetStream Method (String, CultureInfo)

Returns an unmanaged memory stream object from the specified resource, using the specified culture.

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

[ComVisibleAttribute(false)]
public UnmanagedMemoryStream GetStream(
	string name,
	CultureInfo culture
)

Parameters

name
Type: System.String
The name of a resource.
culture
Type: System.Globalization.CultureInfo
An object that specifies the culture to use for the resource lookup. If culture is null, the culture for the current thread is used.

Return Value

Type: System.IO.UnmanagedMemoryStream
An unmanaged memory stream object that represents a resource.

ExceptionCondition
InvalidOperationException

The value of the specified resource is not a MemoryStream object.

ArgumentNullException

name is null.

MissingManifestResourceException

No usable set of resources is found, and there are no neutral resources. For information about how to handle this exception, see the "Handling MissingManifestResourceException and MissingSatelliteAssemblyException Exceptions" section in the ResourceManager class topic.

MissingSatelliteAssemblyException

The default culture's resources reside in a satellite assembly that could not be found. For information about how to handle this exception, see the "Handling MissingManifestResourceException and MissingSatelliteAssemblyException Exceptions" section in the ResourceManager class topic.

The GetStream method takes the name of a resource that is stored as a MemoryStream object, gets the value of the Object resource, and returns an UnmanagedMemoryStream object. The resource lookup is based on the culture specified by the culture parameter. It requires that you work directly with a stream of bytes, which you then convert to an object. This method is useful primarily for performance reasons: Retrieving a resource as a byte stream instead of an explicit object can improve performance.

The returned resource is localized for the culture that is specified by culture, or for the culture that is specified by the CultureInfo.CurrentUICulture property if culture is null. If the resource is not localized for that culture, the resource manager uses fallback rules to load an appropriate resource. If no usable set of localized resources is found, the ResourceManager falls back on the default culture's resources. If a resource set for the default culture is not found, the method throws a MissingManifestResourceException exception. If the resource manager can load an appropriate resource set but cannot find a resource named name, the method returns null.

The IgnoreCase property determines whether the comparison of name with the names of resources is case-insensitive (the default) or case-sensitive.

.NET Framework

Supported in: 4, 3.5, 3.0, 2.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

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