| 12
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 
 |  
#include <stdio.h>
#include <stdlib.h>
#include <windows.h>
#include <string.h>
 
#define path "C:\\Documents and Settings\\Florian\\Mes documents\\les truc a moi\\epf\\3A\\LanguageC"
#define anti "\\"
 
// Prototype de la fonction
void RechArborescence(HANDLE hfind);
 
 
//____________________Programme principal___________________________________
 
int main(int argc, char *argv[])
{
// Déclaration des variables      
HANDLE hfind;
WIN32_FIND_DATA wfd;
hfind = FindFirstFile(path, &wfd); // Répertoire racine
 
RechArborescence(hfind);
 
system("PAUSE");	
return 0;
}
 
//______________Définition de la fonction________________________________
 
void RechArborescence(HANDLE hfind)
{
// Déclaration des variables
WIN32_FIND_DATA wfd;     
 
if (hfind != INVALID_HANDLE_VALUE)
  {
  do
    {
    if (wfd.cFileName[0] != '.')
      {
      // vérifie si c'est un répertoire ou non
      if ( wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY ) 
        {
        printf("c'est un dossier :  ");
        printf ("%s\n", wfd.cFileName);
        // c'est la qu'on introduit notre récursivité
        strcat(path,anti);
        strcat(path,wfd.cFileName);
        RechArborescence(SetCurrentDirectory(path));
        }
      printf ("%s\n", wfd.cFileName);  
      }
    }while (FindNextFile(hfind, &wfd));
 
  // Recherche terminer, ferme la recherche
  FindClose(hfind);
  printf ("Recherche terminee\n");
  }
 
  else
    {
    printf ("Aucun fichier trouve\n");
    }
} | 
Partager