Recherche avec MFC

samijaba Messages postés 10 Date d'inscription jeudi 12 juillet 2007 Statut Membre Dernière intervention 11 mai 2009 - 11 mai 2009 à 10:50
samijaba Messages postés 10 Date d'inscription jeudi 12 juillet 2007 Statut Membre Dernière intervention 11 mai 2009 - 11 mai 2009 à 10:54
bonjour, mon prob est de lister un répertoire avec MFC .
j'ai ce code là mais il ne marche pas pour C:\\ alors qu'il execute avec E:\\
et merci de me lire
void CscanDlg::OnBnClickedOk()
{
    CString cs;
    dest.SetString("");
    cs.SetString("C:\");
AfficherListeFichiers(cs);    // TODO: Add your control notification handler code here

//OnOK();
}
void CscanDlg::AfficherListeFichiers (CString Dossier)
{
CFileFind Find;
Find.
// Change de répertoire
SetCurrentDirectory (Dossier);

BOOL bWorking=Find.FindFile("*.*");
// Début de la recherche

while (bWorking)
{
bWorking = Find.FindNextFile();
if (Find.IsDirectory ()&&Find.GetFileName()!="."&&Find.GetFileName()!="..")
{
AfficherListeFichiers(Find.GetFilePath());
}
 
if(!(Find.IsDirectory ())&&Find.GetFileName()!="."&&Find.GetFileName()!="..")
{
i++;
}
else continue;
}
Find.Close ();
}

1 réponse

samijaba Messages postés 10 Date d'inscription jeudi 12 juillet 2007 Statut Membre Dernière intervention 11 mai 2009
11 mai 2009 à 10:54
 il ya des fautes syntaxique dans l'autre code  je vous donne ce code
void CscanDlg::OnBnClickedOk()
{
    CString cs;
    cs.SetString("C:\");
AfficherListeFichiers(cs);    // TODO: Add your control notification handler code here

//OnOK();
}
void CscanDlg::AfficherListeFichiers (CString Dossier)
{
CFileFind Find;
SetCurrentDirectory (Dossier);
BOOL bWorking=Find.FindFile("*.*");

while (bWorking)
{
bWorking = Find.FindNextFile();
if (Find.IsDirectory ()&&Find.GetFileName()!="."&&Find.GetFileName()!="..")
{
AfficherListeFichiers(Find.GetFilePath());
}
 
if(!(Find.IsDirectory ())&&Find.GetFileName()!="."&&Find.GetFileName()!="..")
{
i++;
}
else continue;
}

Find.Close ();
}
0
Rejoignez-nous