Board index » cppbuilder » write ini files

write ini files


2005-07-06 03:36:35 AM
cppbuilder89
Hi All,
Is there a way to write some comments or newlines in INI file?
I try following code but Invalid Access Exception raised.
TIniFile* file = new TIniFile("test.ini");
try {
file->WriteString("", "", "\n");
}
__finally {
delete file;
}
Thanks,
chenzero
 
 

Re:write ini files

"chenzero" < XXXX@XXXXX.COM >wrote in message
Quote
Hi All,
Is there a way to write some comments or newlines in INI file?
I try following code but Invalid Access Exception raised.
I think that that exception was raised because you did not specify a
section or a key to place that value under. I don't believe that TIniFile
supports adding comments or newlines.
Quote
file->WriteString("", "", "\n");
Jonathan
 

Re:write ini files

"chenzero" < XXXX@XXXXX.COM >wrote in message
Quote
Is there a way to write some comments or newlines in INI file?
The only way to add comments using TIniFile is to append them to the end of
the values you write, ie:
file->WriteString("Section", "Value", "Hello There ; this is a
comment");
Which would result in the following:
[Section]
Value=Hello There ; this is a comment
Not quite sure if that is even legal for INI files to do, though.
You cannot add comments to section names directly, or as standalone lines,
and you cannot insert new lines either.
If you need this level of control, then you will just have to write to the
INI file directly and not use TIniFile at all.
Gambit
 

{smallsort}