1,183
社区成员
发帖
与我相关
我的任务
分享
procedure FindDirUnder(strDir: string; IncludeSelf: boolean; var DirList: TStringList);
// 得到StrDir目录下的子目录以DirList返回
procedure FindFileUnder(strDir, ExtName: string; var FileList: TStringList);
// 得到StrDir目录下的所有以ExtFile('.pas')为扩展名的文件 以FileList返回
procedure FindDirUnder(strDir: string; IncludeSelf: boolean; var DirList: TStringList);
var
SRec: TSearchRec;
retval: Integer;
begin
DirList.Clear;
retval := FindFirst(strDir+'\*.*',faDirectory,sRec);
try
while retval = 0 do
begin
if (SRec.Attr and faDirectory) <> 0 then
if (Srec.Name = '.') or (Srec.Name = '..') then
begin
if IncludeSelf then
DirList.Add(Srec.Name)
end else
DirList.Add(Srec.Name);
retval := FindNext(SRec);
end;
finally
FindClose(SRec);
end;
end;
procedure FindFileUnder(strDir,ExtName:string;var FileList:TStringList);
var
SRec: TSearchRec;
retval: Integer;
begin
FileList.Clear;
retval := FindFirst(strDir+'\'+ExtName,faAnyFile,sRec);
try
while retval = 0 do
begin
if (SRec.Attr and faDirectory) = 0 then
FileList.Add(Srec.Name);
retval := FindNext(SRec);
end;
finally
FindClose(SRec);
end;
end;