I want to save to a configfile in the current directory (".").
I tried with
wxFileConfig( "A", "B", wxEmptyString, "./LocalFile" );
and
wxFileConfig( "A", "B", "./LocalFile" );
all to no avail.
the file is saved always in HOME directory under LINUX.
How can I do this ?
W
On Fri, 4 Nov 2005 01:39:31 +0100, "wim delvaux"
<wim.d...@adaptiveplanet.com> said:
> I want to save to a configfile in the current directory (".").
> I want to save to a configfile in the current directory (".").
I believe that the problem is in the definition of "current directory".
Attached please find my routine for reading config file(s) from
different places.
I suggest to put the directory you like in a string, maybe to update it
upon savin,
and anyhow, use one of the directories delivered by wxStandardPaths, as
shown below.
Good luck
Janos
/// Read the settings from an auto-configuration file
void daqConfiguration::ReadAutoConfiguration(void)
{
// Try to find the autoconfig file in the system, application and
directory
// Try first the system autoconfig file
char separ = wxFileName::GetPathSeparator();
wxStandardPaths S;
m_oldFileName = S.GetConfigDir() + separ + daqConfigFileName;
if(wxFile::Exists(m_oldFileName))
{
pAutoConfig = new wxFileConfig("ESA_MEAS", // AppName
"", // VendorName
m_oldFileName); // LocalFileName
wxLogMessage("Reading system autoconfiguration data from file
'%s'", m_oldFileName);
ReadConfiguration();
delete pAutoConfig; // Do not overwrite
}
else
wxLogMessage("System autoconfig file '%s' not
found",m_oldFileName);
// We are ready with system config file
m_oldFileName = S.GetDataDir() + separ + daqConfigFileName;
if(wxFile::Exists(m_oldFileName))
{ // Config file is present in the application directory
pAutoConfig = new wxFileConfig("ESA_MEAS", // AppName
"", // VendorName
m_oldFileName); // LocalFileName
wxLogMessage("Reading system autoconfiguration data from file
'%s'", m_oldFileName);
ReadConfiguration();
delete pAutoConfig; // Do not overwrite
}
else
wxLogMessage("Application autoconfig file '%s' not
found",m_oldFileName);
// We are ready with both the system and application config files,
// use the one of the user: this config file will also be auto-saved!
m_oldFileName = S.GetUserDataDir() + separ + daqConfigFileName;
// Initialize the "config" feature:
// we're using wxConfig's "create-on-demand" feature: it will create the
// config object when it's used for the first time.
pAutoConfig = new wxFileConfig("ESA_MEAS", // AppName
"", // VendorName
m_oldFileName); // LocalFileName
if(!wxFile::Exists(m_oldFileName))
wxLogMessage("User autoconfig file '%s' not
found",m_oldFileName);
else
wxLogMessage("Reading user autoconfiguration data from file '%s'", m_oldFileName);
wxConfigBase::Set(pAutoConfig);
// Now the autoconfig pointer is set up
ReadConfiguration();
}