0

我需要做这样的事情:

   Private Sub SearchInResources(ByVal PatternSTR As String)
       For Each ResourceFile In My.Resources ' Obviously this don't works
           If ResourceFile.EndsWith(".txt") Then
               Dim fileContent As String = ResourceFile
               Dim stringStream As New System.IO.StringReader(fileContent)
               If stringStream.contains(PatternSTR) Then
                   ' Things...
               End If
           End If
       Next
   End Sub

我已经尝试过这种方法,但对我不起作用!:如何获取资源文件中所有资源的名称

4

2 回答 2

3

这是这样的:

    For Each ResourceFile As DictionaryEntry In My.Resources.ResourceManager.GetResourceSet(Globalization.CultureInfo.CurrentCulture, True, True).OfType(Of Object)()
        If TypeOf (ResourceFile.Value) Is String Then
            MsgBox(My.Resources.ResourceManager.GetObject(ResourceFile.Key))
            'MsgBox(ResourceFile.Key)   ' Resource Name
            'MsgBox(ResourceFile.Value) ' Resource FileContent
        End If
    Next
于 2013-01-10T10:48:14.583 回答
1

您可以将文件存储在文件夹中并通过

For Each Content As String In My.Computer.FileSystem.GetFiles("D:\Resources", FileIO.SearchOption.SearchTopLevelOnly, "*.txt")
    ListBox1.Items.Add(Content)
Next

只是您问题的替代解决方案

于 2013-01-10T03:00:28.633 回答