当前位置: 首页>>代码示例>>VB.NET>>正文


VB.NET ResXResourceReader.BasePath属性代码示例

本文整理汇总了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
开发者ID:VB.NET开发者,项目名称:System.Resources,代码行数:60,代码来源:ResXResourceReader.BasePath

输出:

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


注:本文中的System.Resources.ResXResourceReader.BasePath属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。