Search code examples
vb.netiniread-write

Reading from an ini file with no Sections


I'm using a class similar to this one http://forgottencoders.co.uk/showthread.php?tid=53 but the ini file I'm trying to read from is in a different format. For example it has no section headers at all and the settings are in the following format:

setting1 0
setting2 0
setting_this true

Is there a different way rather than an INI read/write class I can use to easily read/write to this type of INI file? I can think of a few ways like readline but that's a bit.. rough

Coding in VB.Net


Solution

  • Reading the settings you've shown is fairly straightforward and a ReadLine with a String.Split on a space will do (or will be what is happening at the lowest level).

    However, are there settings with more (or less) than one "word" on the RHS (no harder because String.Split can stop at the first space)?

    Are there blank lines or comments and what is the comment markers?