If you really have to use INI files (which is archaic and outdated when there is XML, binary serialization, and the settings file to store information (which is technically an XML file anyway)), then use a managed library that already handles the work for you.

I highly suggest you use Niya's code; it's simple, efficient, and does exactly what you need.