wxFileConfig::DeleteGroup() Not Working

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
spflanze
Earned some good credits
Earned some good credits
Posts: 130
Joined: Tue Feb 15, 2011 10:02 pm

wxFileConfig::DeleteGroup() Not Working

Post by spflanze »

The code in this snipet (wxFileConfig instantiation excluded):

Code: Select all

wxFileConfig *File;
.....

bool result;

File->SetPath( "/Q/bjt/Textbook" );
result = File->DeleteGroup( "Textbook" );
File->Flush();
Does not delete the Textbook group from this file:

Code: Select all

[Q]
[Q/bjt]
[Q/bjt/Textbook]
[Q/bjt/Textbook/spec_h_fe]
U=10
V=88.00000000000000
[Q/bjt/Textbook/spec_h_fe_hf]
U=10
V=80.00000000000000
[Q/bjt/Textbook1]
[Q/bjt/Textbook1/spec_h_fe]
U=10
V=90.00000000000000
[Q/bjt/Textbook1/spec_h_fe_hf]
U=10
V=70.00000000000000
The result variable's value is false after this execution.
What has gone wrong here? How is a group removed from an ini file such as this?
User avatar
doublemax
Moderator
Moderator
Posts: 19160
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: wxFileConfig::DeleteGroup() Not Working

Post by doublemax »

I haven't tried the code, but i guess it should look like this:

Code: Select all

File->SetPath( "/Q/bjt/" );
result = File->DeleteGroup( "Textbook" );
Alternatively, try using an absolute path:

Code: Select all

result = File->DeleteGroup( "/Q/bjt/Textbook" );
Use the source, Luke!
spflanze
Earned some good credits
Earned some good credits
Posts: 130
Joined: Tue Feb 15, 2011 10:02 pm

Re: wxFileConfig::DeleteGroup() Not Working

Post by spflanze »

Your first guess worked. Thank you :)
Post Reply