Utilisation de FindFirst en récursif
Bonjour,
j'utilise la fonction FindFirst en récursif pour scruter les fichiers et sous répertoires d'un répertoire donné.
J'aimerais, dans chaque sous-répertoire, créer un fichier html qui comprend tous les fichiers et les dossiers présents.
Chaque sous répertoire contiendrait un fichier html qui afficherait les dossiers et fichiers contenus dans celui-ci.
Voici mon code :
Code:
1 2 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
| procedure TForm1.Button1Click(Sender: TObject);
var Path: string;
begin
if SelectDirectory('Répertoire', '', Path) = true then
begin
Browse(Path);
end;
end;
procedure TForm1.Browse(Path: string);
var Rec: TSearchRec;
sPath: string;
begin
Path := IncludeTrailingPathDelimiter(Path);
if FindFirst(Path + '*.*', faAnyFile, Rec) = 0 then
repeat
if (Rec.Name <> '.') and (Rec.Name <> '..') then
begin
if (Rec.Attr and faDirectory) <> 0 then
begin
sPath := Path + Rec.FindData.cFileName;
Browse(sPath);
end
else
begin
Memo.Lines.Add('<a href="' + Path + Rec.FindData.cFileName + '">'+ Rec.FindData.cFileName + '</a><br>');
end;
end;
until FindNext(Rec) <> 0;
Memo.Lines.SaveToFile(Path + '\index.html');
Memo.Lines.Clear;
FindClose(Rec);
end; |
... qui ne marche pas !
Vous auriez une idée ?
Merci.
Selticq.