Fais bon usage de ce code, nuns. ;)
Pour le tester :
- 1 TShellTreeView,
- 1 TListBox // pour visualiser l'array of String.
var tFilesPath: array of String;
procedure GetFilesPath(Stv: TShellTreeView; Ext: String);
var
Path: String;
SRec: TSearchRec;
r: Integer;
NbreFich: Integer;
begin
NbreFich := 0;
SetLength(tFilesPath, 0);
Path := IncludeTrailingBackSlash(Stv.Path);
try
r := FindFirst(Path + '*.*', faAnyFile, SRec);
while r = 0 do
begin
if Copy(SRec.Name, 1, 1) <> '.' then
if SRec.Attr and not faDirectory <> 0 then
if LowerCase(ExtractFileExt(SRec.Name)) = LowerCase(Ext) then
begin
Inc(NbreFich);
SetLength(tFilesPath, NbreFich);
tFilesPath[NbreFich -1] := Path + SRec.Name;
end;
r := FindNext(SRec);
end;
FindClose(SRec);
except
ShowMessage('Erreur dans l''exploration de ce répertoire');
end;
end;
procedure TForm1.ShellTreeView1Click(Sender: TObject);
var
i: Integer;
begin
GetFilesPath(ShellTreeView1, '.txt');
// pour visualiser :
ListBox1.Clear;
for i := 0 to Length(tFilesPath) -1 do
ListBox1.Items.Add(tFilesPath[i]);
end;
Bonne prog' :-p
japee