0

I need to do something like this:

   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

I've tried this methods but don't work for me! : How to get the names of all resources in a resource file

Community
  • 1
  • 1
ElektroStudios
  • 19,105
  • 33
  • 200
  • 417

2 Answers2

3

This is the way:

    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
ElektroStudios
  • 19,105
  • 33
  • 200
  • 417
1

You could rather store your files in a folder and access them through

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

just an alternative solution for your problem

Pondidum
  • 11,457
  • 8
  • 50
  • 69
Ley47
  • 123
  • 1
  • 4
  • 14