Gino+89+
13-01-2008, 21:49
Ciao a tutti, ho un grosso problema con i file in wxWidgets...
In poche parole creo un file chiamato profiles.pfl (binario ovviamente, il formato l'ho inventato io) in cui ci salvo la seguente struttura:
typedef struct{
wxString username;
wxString password;
wxString confirmpassword;
wxString name;
wxString surname;
wxString homephone;
wxString workphone;
wxString otherphone;
wxString homeemail;
wxString workemail;
wxString otheremail;
//etc...
}profile;
Il problema sta nel seguente pezzo di codice:
void LoginFrame::access(wxCommandEvent& event)
{
wxFFile infile;
bool accessflag=false;
if(infile.Open(wxT("data/profiles/profiles.pfl"),wxT("rb")))
{
profile currentProfile;
eventsregister->addString(CODE_MES,wxT("Accesso in corso...\n"));
infile.Read(¤tProfile,sizeof(profile));
while(!infile.Eof())
{
if((currentProfile.username).Cmp(profiletextctrl->GetValue())==0)
if((currentProfile.password).Cmp(passtextctrl->GetValue())==0)
accessflag=true;
infile.Read(¤tProfile,sizeof(profile));
}
if((currentProfile.username).Cmp(profiletextctrl->GetValue())==0)
if((currentProfile.password).Cmp(passtextctrl->GetValue())==0)
accessflag=true;
}
else
{
eventsregister->addString(CODE_ERR,wxT("Non posso aprire il profiles file\n"));
}
if(accessflag==true)
eventsregister->addString(CODE_OK,wxT("Accesso avvenuto con successo\n"));
else
eventsregister->addString(CODE_ERR,wxT("Nessun profilo trovato con l'username inserito\n"));
infile.Close();
}
Quando premo il bottone che mi fa partire questa funzione (attraverso la event table) mi si blocca il programma e mi termina l'applicazione.
Quale può essere il motivo secondo voi?
Grazie
In poche parole creo un file chiamato profiles.pfl (binario ovviamente, il formato l'ho inventato io) in cui ci salvo la seguente struttura:
typedef struct{
wxString username;
wxString password;
wxString confirmpassword;
wxString name;
wxString surname;
wxString homephone;
wxString workphone;
wxString otherphone;
wxString homeemail;
wxString workemail;
wxString otheremail;
//etc...
}profile;
Il problema sta nel seguente pezzo di codice:
void LoginFrame::access(wxCommandEvent& event)
{
wxFFile infile;
bool accessflag=false;
if(infile.Open(wxT("data/profiles/profiles.pfl"),wxT("rb")))
{
profile currentProfile;
eventsregister->addString(CODE_MES,wxT("Accesso in corso...\n"));
infile.Read(¤tProfile,sizeof(profile));
while(!infile.Eof())
{
if((currentProfile.username).Cmp(profiletextctrl->GetValue())==0)
if((currentProfile.password).Cmp(passtextctrl->GetValue())==0)
accessflag=true;
infile.Read(¤tProfile,sizeof(profile));
}
if((currentProfile.username).Cmp(profiletextctrl->GetValue())==0)
if((currentProfile.password).Cmp(passtextctrl->GetValue())==0)
accessflag=true;
}
else
{
eventsregister->addString(CODE_ERR,wxT("Non posso aprire il profiles file\n"));
}
if(accessflag==true)
eventsregister->addString(CODE_OK,wxT("Accesso avvenuto con successo\n"));
else
eventsregister->addString(CODE_ERR,wxT("Nessun profilo trovato con l'username inserito\n"));
infile.Close();
}
Quando premo il bottone che mi fa partire questa funzione (attraverso la event table) mi si blocca il programma e mi termina l'applicazione.
Quale può essere il motivo secondo voi?
Grazie