No i coś wykombinowałem - dzięki za pomoc
{
Procedura FoldersAndFilesInFolder podaje sciezki wszystkich folderów i plików
znajdujących się w foderze okreslonym scieżką dir_path. Na formie jest Memo i Button dla przetestowania procedury
}
Tdirs_path =array of string;
Tfiles_path=array of string;
Tdir=record
dir_path:string;//scieżka foldeu
dirs_path:Tdirs_path;//scieżki folderów znajdujących się w tym folderze
files_path:Tfiles_path;//sciezki plików znajdujących się w tym folderze
end;
Tdirs=array of Tdir;
var
Form1: TForm1;
procedure FoldersAndFilesInFolder(dir_path:string;var dirs:Tdirs);
implementation
{$R *.DFM}
procedure FoldersAndFilesInFolder(dir_path:string;var dirs:Tdirs);
var
dirs_path1:Tdirs_path;
files_path1:Tfiles_path;
start:Integer;
//pliki
procedure FilesP(dir_path:string;var files_path:Tfiles_path);
var
info_f:TSearchRec;
ok_f,count_f:Integer;
procedure AddFileP;//dodaj scieżkę pliku
begin
Inc(count_f);
SetLength(files_path,count_f);
files_path[count_f-1]:=dir_path+'\\'+info_f.name;
end;
begin
count_f:=0;
ok_f:=FindFirst(dir_path+'\\*.*',faArchive,info_f);
if ok_f=0 then
begin
AddFileP;
repeat
ok_f:=FindNext(info_f);
if ok_f=0 then
AddFileP;
until ok_f<>0;
end;
FindClose(info_f);
end;
//foldery
procedure DirsP(dir_path:string;var dirs_path:Tdirs_path);
var
info_d:TSearchRec;
ok_d,count_d:Integer;
procedure AddDirP;//dodaj scieżkę folderu
begin
Inc(count_d);
SetLength(dirs_path,count_d);
dirs_path[count_d-1]:=dir_path+'\\'+info_d.name;
end;
begin
count_d:=0;
ok_d:=FindFirst(dir_path+'\\*',faAnyFile,info_d);
if ok_d=0 then
begin
if ((info_d.Attr and faDirectory)=faDirectory)and
((info_d.name<>'.')and(info_d.name <> '..')) then
AddDirP;
repeat
ok_d:=FindNext(info_d);
if ok_d=0 then
begin
if ((info_d.Attr and faDirectory)=faDirectory)and
((info_d.name<>'.')and(info_d.name <> '..')) then
AddDirP;
end;
until ok_d<>0;
end;
FindClose(info_d);
end;
procedure FoldersAndFilesInFolderEx(dir_path:string;var nr_dir:Integer;var dirs:Tdirs);
var
d:Integer;
begin
SetLength(dirs_path1,0);
SetLength(files_path1,0);
DirsP(dir_path,dirs_path1);
FilesP(dir_path,files_path1);
SetLength(dirs,nr_dir+1);
dirs[nr_dir].dir_path:=dir_path;
dirs[nr_dir].dirs_path:=dirs_path1;
dirs[nr_dir].files_path:=files_path1;
Inc(nr_dir);
if Length(dirs_path1)>0 then
begin //wywolanie rekurencyjne
for d:=0 to High(dirs_path1) do
FoldersAndFilesInFolderEx(dirs_path1[d],nr_dir,dirs);
end;
end;
begin
start:=0;
FoldersAndFilesInFolderEx(dir_path,start,dirs);
end;
procedure TForm1.Button1Click(Sender: TObject);
var
dirs:Tdirs;
ds,d,f:Integer;
begin
Memo1.Clear;
FoldersAndFilesInFolder('C:\\Windows\\Pulpit\\Nowy',dirs);
for ds:=0 to High(dirs)do
begin
Memo1.Lines.Add(dirs[ds].dir_path);
for d:=0 to High(dirs[ds].dirs_path) do
Memo1.Lines.Add(' folder nr '+IntToStr(d+1)+' '+dirs[ds].dirs_path[d]);
for f:=0 to High(dirs[ds].files_path) do
Memo1.Lines.Add(' plik nr '+IntToStr(f+1)+' '+dirs[ds].files_path[f]);
end;
end;