M
mossmud
Unregistered / Unconfirmed
GUEST, unregistred user!
怎样查找莫一个指定目录下的所有文件,包括子目录。并把它放到一个stringlist里面?
我搜索过以前的解答,好像不行。
sL:TStringList;
procedure SearchFile(path:string);
var
sr: TSearchRec;
begin
if FindFirst(path+'/*',faanyfile, sr) = 0 then
begin
if (sr.Attr and (faDirectory or faVolumeID))<> 0 then
SearchFile(path+'/'+sr.name)
else sL.add(sr.name); //如何知道这个文件的路径???
while FindNext(sr) = 0 do
begin
if (sr.Attr and (faDirectory or faVolumeID))<> 0 then
SearchFile(path+'/'+sr.name)
else sL.add(sr.name);
end;
end;
findclose(sr);
end;
我搜索过以前的解答,好像不行。
sL:TStringList;
procedure SearchFile(path:string);
var
sr: TSearchRec;
begin
if FindFirst(path+'/*',faanyfile, sr) = 0 then
begin
if (sr.Attr and (faDirectory or faVolumeID))<> 0 then
SearchFile(path+'/'+sr.name)
else sL.add(sr.name); //如何知道这个文件的路径???
while FindNext(sr) = 0 do
begin
if (sr.Attr and (faDirectory or faVolumeID))<> 0 then
SearchFile(path+'/'+sr.name)
else sL.add(sr.name);
end;
end;
findclose(sr);
end;