Files Count

Résolu
papyvore Messages postés 223 Date d'inscription samedi 15 novembre 2003 Statut Membre Dernière intervention 16 décembre 2021 - 28 janv. 2018 à 17:37
papyvore Messages postés 223 Date d'inscription samedi 15 novembre 2003 Statut Membre Dernière intervention 16 décembre 2021 - 29 janv. 2018 à 10:56
Bonjour,
Function FileCount(Chemin: String): Integer;
Var
S: TSearchRec;
Begin
Chemin := IncludeTrailingPathDelimiter(Chemin);
Result := 0;
If FindFirst(Chemin + '*.jpg', faAnyFile, S) = 0 Then
Begin
Repeat
If (S.Name <> '.') And (S.Name <> '..') Then
Begin
If (S.Attr And faDirectory) <> 0 Then
Result := Result + FileCount(Chemin + S.FindData.cFileName)
Else
Inc(Result);
End;
// Recherche du suivant
Until FindNext(S) <> 0;
FindClose(S);
End;
End;

la fonction sort de la boucle au premier dossier et ,ne prend pas en compte les sous dossiers ??
je ne comprend pas mon erreur .
d'autant que je retrouve la même fonction sur le net
ça marche pas sous windows 10 ????

1 réponse

Salut,
Function FileCount(Chemin, AFileExt: String; AIgnoreCase: Boolean = False): Integer;
Var
  S: TSearchRec;
Begin
  Chemin := IncludeTrailingPathDelimiter(Chemin);
  Result := 0;
  If FindFirst(Chemin + '*.*', faAnyFile, S) = 0 Then
  Begin
    Repeat
      If (S.Name <> '.') And (S.Name <> '..') Then
      Begin
        If (S.Attr And faDirectory) <> 0 Then
          Result := Result + FileCount(Chemin + S.FindData.cFileName, AFileExt)
        Else
          If AIgnoreCase Then
          Begin
            If UpperCase(ExtractFileExt(S.Name)) = UpperCase('.' + AFileExt) Then
              Inc(Result);
          End
          Else
            If ExtractFileExt(S.Name) = '.' + AFileExt Then
              Inc(Result);
      End;
      // Recherche du suivant
    Until FindNext(S) <> 0;
    FindClose(S);
  End;
End;
@+
0
papyvore Messages postés 223 Date d'inscription samedi 15 novembre 2003 Statut Membre Dernière intervention 16 décembre 2021 15
29 janv. 2018 à 10:56
salut merci
0
Rejoignez-nous