Is there a way to make the ini file easy to see?

78 Views Asked by At

I made a INI file using C# script (GetPrivateProfileString, WritePrivateProfileString)

and the result is below

[SectionA]
valueA=0
valueB=1
valueC=2
[SectionB]
valueD=0
valueE=1
valueF=2

but this file is hard to see
The results I want are as follows.

[SectionA]
valueA=0
valueB=1
valueC=2

[SectionB]
valueD=0
valueE=1
valueF=2

To make like this, i wrote valueC's value with \n
However, if the order was different, I had strange results.
like this

[SectionA]
valueC=2

valueA=0
valueB=1
[SectionB]
valueD=0
valueE=1
valueF=2

So I want to know how to make this.
Please let me know

1

There are 1 best solutions below

0
Qiang Fu On

Read to string and:

Replace("[","\n["));
Replace("\n\n\n","\n\n");   //prevent from depulicated "\n"
Replace("\n[SectionA]","[SectionA]");    //delete the first "\n"

Write string to file