Menu

How do you get all keys for a section (VB)?

Help
Ken Phipps
2011-12-07
2013-04-22
  • Ken Phipps

    Ken Phipps - 2011-12-07

    How can you get all key names for a certain section? For example, you have a section called 'Settings' and you want to get a list of all key names in that section. I want to be able to get all section names, then use them to get all key names for each section to put into an array or control.

    This is for a simple ini editor where you don't know the section/key names in advance.

     
  • Brent R. Matzelle

    I haven't tried VB in ages so forgive me if it doesn't compile right off the bat. 

    Dim source As IConfigSource  = New IniConfigSource()
    source.Load("MyApp.ini")
    Dim keys() As String =  source.Config("Settings").GetKeys()
    For Each key As String in keys
      Console.WriteLine("Key: " & key & ", Value: " & source.Configs("Settings").Get(key))
    Next
    
     

Log in to post a comment.

MongoDB Logo MongoDB