function TFileSearcher.GetAllFile(path: string): TStringList;
var
found : integer;
rec : TSearchRec;
childPaths : TStringList;
ext : string;
begin
Result := TStringList.Create(); found := FindFirst( path + '\*', faAnyFile, rec ); while( found = 0 ) do
begin
Application.ProcessMessages(); if (rec.Name <> '.') And (rec.Name <> '..') then
begin
if ((rec.Attr And faDirectory) = faDirectory) then
begin
childPaths := GetAllFile( path + '\' + rec.Name );
Result.AddStrings( childPaths );
end
else
begin
ext := ExtractFileExt( rec.Name );
Delete( ext, 1, 1 );
//if the file type is in the typeList, Add it to result set.
if fileTypeList.IndexOf( ext ) <> -1 then
begin
Result.Add( path + '\' + rec.Name );
end;
end;
end; found := FindNext( rec );
end; SysUtils.FindClose( rec );
end;
var
found : integer;
rec : TSearchRec;
childPaths : TStringList;
ext : string;
begin
Result := TStringList.Create(); found := FindFirst( path + '\*', faAnyFile, rec ); while( found = 0 ) do
begin
Application.ProcessMessages(); if (rec.Name <> '.') And (rec.Name <> '..') then
begin
if ((rec.Attr And faDirectory) = faDirectory) then
begin
childPaths := GetAllFile( path + '\' + rec.Name );
Result.AddStrings( childPaths );
end
else
begin
ext := ExtractFileExt( rec.Name );
Delete( ext, 1, 1 );
//if the file type is in the typeList, Add it to result set.
if fileTypeList.IndexOf( ext ) <> -1 then
begin
Result.Add( path + '\' + rec.Name );
end;
end;
end; found := FindNext( rec );
end; SysUtils.FindClose( rec );
end;
这是错误的截图。
//begin
Result.Add( path + '\' + rec.Name );
//end;把这个地方注视掉再试试