Drawing Choice from a Loop

I am using a loop to find all the .txt files in a folder, and was wonder how I could create a new choice for a DComboBox for each text file there is.

For example,


just pseudo code but you could essentially do something like:

local files, folders = file.Find(“folder with text files/*.txt”, “DATA”);
for k, v in pairs(files) do
// sorry this is probably wrong syntax
// k is the file name as a string (should have .txt extension)

My code is pretty much that, but that does not work. I get this error.

[ERROR] lua/includes/util.lua:184: bad key to string index (number expected, got string)

  1. error - [C]:-1
  2. __index - lua/includes/extensions/string.lua:262
    3. IsValid - lua/includes/util.lua:184
    4. AddItem - lua/vgui/dpanellist.lua:134
    5. unknown - lua/autorun/client/a.lua:66


That only errors because of the AddItem(v).
My code is this.
local files, dirs = file.Find(“logs/*.txt”,“DATA”)
for k, dir in pairs(files) do

Msg(k … " ", dir … "

List = vgui.Create( “DPanelList”, MainScreen )
List:SetPos( 25,25 )
List:SetSize( 200, 200 )
List:SetSpacing( 5 )
List:EnableVerticalScrollbar( true )

local example1 = vgui.Create( “DCheckBoxLabel” )
example1:SetText( “example1” )
List:AddItem( example1 )

List:AddItem( dir ) 


I found another way to make this from that code, so thanks.