[RESOLVED] Populate Listview with files in my.resources
Hello, I wonder if you can help me please.
I have a very simple program which simply populates a listbox with a list of files stored in a directory.
Code:
Try
lvScripts.View = View.Details
lvScripts.Items.Clear()
lvScripts.Columns.Clear()
lvScripts.Columns.Add("Filename", 250, HorizontalAlignment.Left)
Dim dFolder As DirectoryInfo = New DirectoryInfo(ScriptDirectory)
Dim fFileArray() As FileInfo = dFolder.GetFiles
Dim fFile As FileInfo
Dim lCurrent As ListViewItem
For Each fFile In fFileArray
lCurrent = lvScripts.Items.Add(fFile.Name)
Next
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
However, I'd like to embed these files into the application itself and open them from there rather than from looking at the directory.
To this end I've added each of the files as a resource but I don't know how to populate the list view with a list of the text files in the my.resources rather than a list of the text files in the directory.
Re: Populate Listview with files in my.resources
You can try calling ResourceManager.GetResourceSet() and iterating through the ResourceSet it returns.
Re: Populate Listview with files in my.resources
mf12's idea was correct. here's how:
vb Code:
Dim ResourceSet As Resources.ResourceSet = My.Resources.ResourceManager.GetResourceSet(Globalization.CultureInfo.CurrentCulture, True, True)
ListView1.Items.AddRange(ResourceSet.Cast(Of DictionaryEntry) _
.Select(Function(d) New ListViewItem(d.Key.ToString)).ToArray)