一:获取指定文件夹的文件
复制代码 代码如下:
procedure searchfile(path:string);//注意,path后面要有'\';
var
SearchRec:TSearchRec;
found:integer;
begin
found:=FindFirst(path+'*.*',faAnyFile,SearchRec);
while found=0 do
begin
if (SearchRec.Name<>'.') and (SearchRec.Name<>'..')
and (SearchRec.Attr<>faDirectory) then
ListBox1.Add(SearchRec.Name);
found:=FindNext(SearchRec);
end;
FindClose(SearchRec);
end;

二:获取该目录下的子目录的文件
复制代码 代码如下:
procedure SearchFile(path:string);
var
SearchRec:TSearchRec;
found:integer;
begin
found:=FindFirst(path+'*.*',faAanyFile,SearchRec);
while found=0 do
begin
if (SearchRec.Name<>'.') and (SearchRec.name<>'..) and
(SearchRec.Name=faDirectory) then
SearchFile(SearchRec.Name+'\')
else
LisBox1.Add(SearchRec.Name);
found:=FindNext(SearchREc);
end;
FindClose(SearchRec);
end;
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!