获取目录下所有文件名的代码
程序员文章站
2022-06-02 15:58:24
一:获取指定文件夹的文件 复制代码 代码如下: procedure searchfile(path:string);//注意,path后面要有'\'; var search...
一:获取指定文件夹的文件
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;
复制代码 代码如下:
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;
上一篇: 百度云网盘如何取消关注(图文)
下一篇: 2345王牌浏览器鼠标手势设置技巧图解