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 34 35 36 37 38
| procedure TForm1.ListerTousFichier(const Chemin, Fichier,
RacineWeb: string; const InDir: boolean; var listFichier: TStrings);
var
Rec : TSearchRec;
Path, strNouvPath : string;
begin
Path := IncludeTrailingBackslash(Chemin);
//Cherche tous les fichiers seulement
if FindFirst(Path + Fichier, faAnyFile - faDirectory, Rec) = 0 then
try
repeat
//listFichier.Add({Path} + Rec.Name);
//Enlève le chemin local et le "\" final
//Remplace les "\" par des "/" pour le protocole HTTP
strNouvPath := StringReplace(Copy(Path,Length(chemin)+2,Length(Path)),'\','/',[rfReplaceAll]);
listFichier.Add('_____'+Rec.Name);
until FindNext(Rec) <> 0;
finally
FindClose(Rec);
end;
//Si n'est pas dans un fichier
If not InDir then Exit;
//Cherche le prochain dossier
if FindFirst(Path + '*.*', faDirectory, Rec) = 0 then
try
repeat
if (Rec.Attr = faDirectory) and (Rec.Name<>'.') and (Rec.Name<>'..') then
begin
listFichier.Add('#'+Rec.Name);
ListerTousFichier(Path + Rec.Name, Fichier, RacineWeb,True,listFichier);
end;
until FindNext(Rec) <> 0;
finally
FindClose(Rec);
end;
end; |
Partager