本文整理汇总了VB.NET中System.Resources.ResXResourceReader.BasePath属性的典型用法代码示例。如果您正苦于以下问题:VB.NET ResXResourceReader.BasePath属性的具体用法?VB.NET ResXResourceReader.BasePath怎么用?VB.NET ResXResourceReader.BasePath使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类System.Resources.ResXResourceReader
的用法示例。
在下文中一共展示了ResXResourceReader.BasePath属性的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的VB.NET代码示例。
示例1: Example
' 导入命名空间
Imports System.Collections
Imports System.ComponentModel.Design
Imports System.Drawing
Imports System.Reflection
Imports System.Resources
Module Example
Public Sub Main()
CreateXMLResourceFile()
' Read the resources in the XML resource file.
Dim resx As New ResXResourceReader("DogBreeds.resx")
Console.WriteLine("Default Base Path: '{0}'", resx.BasePath)
resx.BasePath = "C:\Data\"
Console.WriteLine("Current Base Path: '{0}'", resx.BasePath)
Console.WriteLine()
resx.UseResXDataNodes = True
Dim dict As IDictionaryEnumerator = resx.GetEnumerator()
Dim assemblyNames() As AssemblyName =
{ New AssemblyName(GetType(Bitmap).Assembly.FullName) }
Do While dict.MoveNext()
Dim node As ResXDataNode = CType(dict.Value, ResXDataNode)
If node.FileRef IsNot Nothing Then
Dim image As Object = node.GetValue(assemblyNames)
Console.WriteLine("{0}: {1} from {2}", dict.Key, image.GetType().Name, node.FileRef.Filename)
Else
Console.WriteLine("{0}: {1}", node.Name, node.GetValue(CType(Nothing, ITypeResolutionService)))
End If
Loop
End Sub
Private Sub CreateXMLResourceFile()
' Define an array of ResXFileRef objects for images.
Dim typeName As String = String.Format("{0}, {1}", GetType(Bitmap).Fullname, GetType(Bitmap).Assembly.FullName)
Dim imageRefs() As ResXFileRef =
{ New ResXFileRef("images\Akita.jpg", typeName),
New ResXFileRef("images\Dalmatian.jpg", typeName),
New ResXFileRef("images\Husky.jpg", typeName),
New ResXFileRef("images\GreatPyrenees.jpg", typeName),
New ResXFileRef("images\Malamute.jpg", typeName),
New ResXFileRef("images\Newfoundland.jpg", typeName),
New ResXFileRef("images\Rottweiler.jpg", typeName)
}
Using resx As New ResXResourceWriter(".\DogBreeds.resx")
' Add each ResXFileRef object to the resource file.
For Each imageRef In imageRefs
' Form resource name from name of image.
Dim name As String = imageRef.FileName
name = name.Substring(name.IndexOf("\") + 1)
name = name.Substring(0, name.IndexOf("."))
Dim node As New ResXDataNode(name, imageRef)
resx.AddResource(node)
Next
resx.AddResource("CreatedBy", GetType(Example).Assembly.FullName)
End Using
End Sub
End Module
输出:
Default Base Path: '' Current Base Path: 'C:\Data\' Akita: Bitmap from C:\Data\images\Akita.jpg Dalmatian: Bitmap from C:\Data\images\Dalmatian.jpg Husky: Bitmap from C:\Data\images\Husky.jpg GreatPyrenees: Bitmap from C:\Data\images\GreatPyrenees.jpg Malamute: Bitmap from C:\Data\images\Malamute.jpg Newfoundland: Bitmap from C:\Data\images\Newfoundland.jpg Rottweiler: Bitmap from C:\Data\images\Rottweiler.jpg CreatedBy: BasePathEx1, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null