public class ResXManager
Public Class ResXManager
Dim instance As ResXManager
public ref class ResXManager
type ResXManager = class end
No code example is currently available or this language may not be supported.
No code example is currently available or this language may not be supported.
Dim resX As New ResXManager(Path.Combine(Application.StartupPath, "MyResources.ResX"))
With resX
' Create or overwrite the ResX file.
.Create(overwrite:=True)
' Add a string resource.
Dim resStr As New Resource(Of String)("String Resource", "Hello World!", "String Comment")
.AddResource(Of String)(resStr)
' Add a bitmap resource.
Dim resBmp As New Resource(Of Bitmap)("Bitmap Resource", SystemIcons.Information.ToBitmap, "Bitmap Comment")
.AddResource(Of Bitmap)(resBmp)
' Add a binary resource.
Dim resBin As New Resource(Of Byte())("Binary Resource", File.ReadAllBytes("C:\File.mp3"), "Binary Comment")
.AddResource(Of Byte())(resBin)
End With
' *******************************************************************************************************
' Get the string resource.
Dim stringResource As Resource(Of String) =
resX.FindResource(Of String)("String Resource", StringComparison.OrdinalIgnoreCase)
' Get the bitmap resource.
Dim bitmapResource As Resource(Of Bitmap) =
resX.FindResource(Of Bitmap)("Bitmap Resource", StringComparison.OrdinalIgnoreCase)
' Get the binary resource.
Dim binaryResource As Resource(Of Byte()) =
resX.FindResource(Of Byte())("Binary Resource", StringComparison.OrdinalIgnoreCase)
' *******************************************************************************************************
' Get the string data.
Dim stringData As String = stringResource.Data
' Get the bitmap data.
Dim bitmapData As Bitmap = bitmapResource.Data
' Get the binary data.
Dim binaryData As Byte() = binaryResource.Data
' *******************************************************************************************************
' Get all the resources at once.
Dim resources As IEnumerable(Of Resource) = resX.Resources
' Get all the resources of specific Type at once.
Dim stringResources As IEnumerable(Of Resource(Of String)) = resX.FindResources(Of String)()
' *******************************************************************************************************
' Get all the resource datas at once from Resource collection.
Dim resourceDatas As IEnumerable(Of Object) =
From res As Resource In resX.Resources
Select res.Data
' Get all the resource datas of specific Type at once from Resource collection.
Dim stringResourceDatas As IEnumerable(Of String) =
From res As Resource In resX.Resources
Where res.Type Is GetType(String)
Select DirectCast(res.Data, String)
' *******************************************************************************************************
' Treat the string data as you like.
MessageBox.Show(stringData, String.Empty, MessageBoxButtons.OK, MessageBoxIcon.Information)
' Treat the bitmap data as you like.
Me.Icon = Icon.FromHandle(bitmapData.GetHicon)
' Treat the binary data as you like.
File.WriteAllBytes("C:\new file.mp3", binaryData)
' *******************************************************************************************************
' Iterate all the resources.
For Each res As Resource In resX.Resources
Dim sb As New Global.System.Text.StringBuilder
sb.AppendLine(String.Format("Name...: {0}", res.Name))
sb.AppendLine(String.Format("Comment: {0}", res.Comment))
sb.AppendLine(String.Format("Type...: {0}", res.Data.GetType().FullName))
sb.AppendLine(String.Format("Data...: {0}", res.Data.ToString()))
MsgBox(sb.ToString())
Next res
' Iterate all the resources of specific Type.
For Each res As Resource(Of String) In resX.FindResources(Of String)()
Dim sb As New Global.System.Text.StringBuilder
sb.AppendLine(String.Format("Name...: {0}", res.Name))
sb.AppendLine(String.Format("Comment: {0}", res.Comment))
sb.AppendLine(String.Format("Type...: {0}", res.Type.ToString()))
sb.AppendLine(String.Format("Data...: {0}", res.Data.ToString()))
MsgBox(sb.ToString())
Next res
' *******************************************************************************************************
' Remove a resource.
resX.RemoveResource("Binary Resource")
' GC.Collect()
End Sub
No code example is currently available or this language may not be supported.
No code example is currently available or this language may not be supported.
No code example is currently available or this language may not be supported.
No code example is currently available or this language may not be supported.
ResXManager | Initializes a new instance of the ResXManager class. |
FilePath | Gets the .NET managed resource file path. |
Resources | Gets the resources contained in the .NET managed resource file. |
AddResource(String, Object, String) | Adds a resource into the .NET managed resource file. |
AddResourceT(ResourceT) | Adds a resource into the .NET managed resource file. |
AddResourceT(String, T, String) | Adds a specified resource of the specified type into the .NET managed resource file. |
Create | Creates the .NET managed resource file. |
Equals | Determines whether the specified object is equal to the current object. (Inherited from Object) |
FindResource(String, StringComparison) | Finds a resource by the specified name inside the .NET managed resource file. |
FindResourceT(String, StringComparison) | Finds a resource by the specified name of specified type inside the .NET managed resource file. |
FindResourcesT | Finds the resources of the specified type inside the .NET managed resource file. |
GetHashCode | Serves as the default hash function. (Inherited from Object) |
GetType | Gets the Type of the current instance. (Inherited from Object) |
RemoveResource | Removes a resource by the specified name from the .NET managed resource file. |
ReplaceResource(String, Object, String) | Replaces a resource by the specified name inside the .NET managed resource file. |
ReplaceResourceT(ResourceT) | Replaces a resource by the specified name inside the .NET managed resource file. |
ReplaceResourceT(String, T, String) | Replaces a resource by the specified name of the specified type inside the .NET managed resource file. |
ToString | Returns a string that represents the current object. (Inherited from Object) |
CanConvertTo |
Determines whether the source object can be converted to the specified target type.
(Defined by ObjectExtensions) |
CanConvertToT |
Determines whether the source object can be converted to the specified target type.
(Defined by ObjectExtensions) |
ConvertToT |
Converts an object to the specified target type.
If the conversion fails, an exception is thrown.
(Defined by ObjectExtensions) |
ConvertToT |
Converts an object to the specified target type.
If the conversion fails, returns the specified default value.
(Defined by ObjectExtensions) |
IsDisposable |
Determines whether the specified object is a disposable type
(i.e., it implements IDisposable interface).
(Defined by ObjectExtensions) |
Speak |
Speaks the string representation of the source object by using the
operating system integrated text-to-speech synthesizer.
(Defined by ObjectExtensions) |
Speak |
Speaks the string representation of the source object by using the
operating system integrated text-to-speech synthesizer.
(Defined by ObjectExtensions) |
ThrowIfNullTException |
Throws the specified exception if the source object is null.
(Defined by ObjectExtensions) |