获取目录下所有文件名的代码
时间:2022-08-20 12:25:14
一:获取指定文件夹的文件
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;
标签:目录,文件名
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
golang协程与线程区别简要介绍
2024-02-06 10:58:46
![](https://img.aspxhome.com/file/2023/1/105141_0s.png)
C#编码好习惯小结
2024-05-02 17:20:20
Python全栈之学习CSS(1)
2022-11-07 19:05:18
![](https://img.aspxhome.com/file/2023/9/94039_0s.jpg)
Python2和Python3之间的str处理方式导致乱码的讲解
2022-10-01 09:46:53
判断触发器正在处理的是插入,删除还是更新触发
2012-01-29 18:30:34
一篇文章带你入门SQL编程
2024-01-12 13:05:22
![](https://img.aspxhome.com/file/2023/0/109830_0s.png)
python实现移位加密和解密
2022-03-20 09:09:27
![](https://img.aspxhome.com/file/2023/6/105726_0s.jpg)
eWebEditor 辑器按钮失效 IE8下eWebEditor编辑器无法使用的解决方法
2023-06-27 07:07:26
![](https://img.aspxhome.com/file/2023/4/70624_0s.gif)
基于Element的组件改造的树形选择器(树形下拉框)
2024-05-28 16:01:30
![](https://img.aspxhome.com/file/2023/8/123078_0s.png)
使用JavaScript构建JSON格式字符串实现步骤
2024-04-18 09:42:12
CKEditor/FCKEditor 使用 CKeditor 3.0.1 快速使用教程(含插入图片)
2022-10-16 14:04:14
关于jquery css的使用介绍
2024-04-22 22:21:45
python基于paramiko将文件上传到服务器代码实现
2022-05-20 06:14:44
python进度条显示之tqmd模块
2021-09-29 22:44:36
![](https://img.aspxhome.com/file/2023/9/85179_0s.png)
python数据解析BeautifulSoup爬取三国演义章节示例
2021-03-21 13:27:27
![](https://img.aspxhome.com/file/2023/2/104982_0s.jpg)
numpy数组切片的使用
2023-10-30 04:36:24
![](https://img.aspxhome.com/file/2023/9/67249_0s.png)
悟道Web标准:让W3C标准兼容终端
2009-10-11 16:40:00
Golang中数据结构Queue的实现方法详解
2024-04-26 17:20:00
idea创建springMVC框架和配置小文件的教程图解
2021-04-03 15:22:54
![](https://img.aspxhome.com/file/2023/1/78601_0s.png)
python学习之whl文件解释与安装详解
2021-11-01 18:09:14
![](https://img.aspxhome.com/file/2023/8/121078_0s.png)