社区
Delphi
帖子详情
英雄啊,救救我吧!在线等....
Sir_Java
2003-10-21 01:30:00
怎样找出一个指定路径下的所有文件夹及文件?
...全文
47
2
打赏
收藏
英雄啊,救救我吧!在线等....
怎样找出一个指定路径下的所有文件夹及文件?
复制链接
扫一扫
分享
转发到动态
举报
写回复
配置赞助广告
用AI写文章
2 条
回复
切换为时间正序
请发表友善的回复…
发表回复
打赏红包
pankun
2003-10-21
打赏
举报
回复
转贴子给你参考:
查找所有文件
procedure findall(disk,path: String; var fileresult: Tstrings);
var
fpath: String;
fs: TsearchRec;
begin
fpath:=disk+path+'\*.*';
if findfirst(fpath,faAnyFile,fs)=0 then
begin
if (fs.Name<>'.')and(fs.Name<>'..') then
if (fs.Attr and faDirectory)=faDirectory then
findall(disk,path+'\'+fs.Name,fileresult)
else
fileresult.add(disk+strpas(strupper(pchar(path)))+'\'+strpas(
strupper(pchar(fs.Name)))+'('+inttostr(fs.Size)+')');
while findnext(fs)=0 do
begin
if (fs.Name<>'.')and(fs.Name<>'..') then
if (fs.Attr and faDirectory)=faDirectory then
findall(disk,path+'\'+fs.Name,fileresult)
else
fileresult.add(disk+strpas(strupper(pchar(path)))+'\'+str
pas(strupper(pchar(fs.Name)))+'('+inttostr(fs.Size)+')');
end;
end;
findclose(fs);
end;
procedure DoSearchFile(Path: string; Files: TStrings = nil);
var
Info: TSearchRec;
procedure ProcessAFile(FileName: string);
begin
if Assigned(PnlPanel) then
PnlPanel.Caption := FileName;
Label2.Caption := FileName;
end;
function IsDir: Boolean;
begin
with Info do
Result := (Name <> '.') and (Name <> '..') and ((attr and fadirectory) = fadirectory);
end;
function IsFile: Boolean;
begin
Result := not ((Info.Attr and faDirectory) = faDirectory);
end;
begin
Path := IncludeTrailingBackslash(Path);
try
if FindFirst(Path + '*.*', faAnyFile, Info) = 0 then
if IsFile then
ProcessAFile(Path + Info.Name)
else if IsDir then DoSearchFile(Path + Info.Name);
while FindNext(Info) = 0 do
begin
if IsDir then
DoSearchFile(Path + Info.Name)
else if IsFile then
ProcessAFile(Path + Info.Name);
Application.ProcessMessages;
if QuitFlag then Break;
Sleep(100);
end;
finally
FindClose(Info);
end;
end;
hongqi162
2003-10-21
打赏
举报
回复
能不能说得清楚点?
6年前端开发找不到工作,只能去外包!12月初被裁,想找平薪20K的工作,但面试多家公司都没有下文!...
还是我技术太差,别人不想要?
救救
孩子吧,都宅家焦虑惨了!6年前端找不到工作,只能去外包了!网友问楼主什么学历,楼主说三本。有人说,都工作这么久了,为什么还拿工作年限和工资挂钩?有...
【上班摸鱼系列】文字选择类游戏:《职员默示录 - 启》末日丧尸爆发,你,是什么下场!?...
等人好些了再进【题目47】 题目25 你没有招呼大家,也许这种时候更体现人类自私的一面吧,你回头看了眼座位上的背包,里面有女神小莉的照片,在上次团建时候偷拍的,是你YY的对象 不带【题目48】 带...
《狂人日记》(书感)
我偏要对这伙人说,“你们可以改了,从真心改起!要晓得将来容不得吃人的人,活在世上。 “你们要不改,自己也会吃尽。即使生得多,也会给真的人除灭了,同猎人打完狼子一样!——同虫子一样!” ...... 可是偏要说...
壮士请留步,
英雄
游戏笔试真题公开(春招&;实习在招)
对欧子的印象还停留在跟我毫无相关的,求职根本不会考虑的,产品也不用的,现在感觉离我越来越近了,我主要对这个掉发问题很感兴趣,如果能解决我的掉发问题,我愿意当欧孝。----无项目,八股拷打,面试官人很好 ...
电影:钢铁侠3
我在外面等你 Okay. 好的 So why am I telling you this? 为什么我要讲这一段呢 Because I had just created demons, 因为我刚种下了自己的祸根 and I didn't even know it. 而且我完全没意识到 No English 你知道...
Delphi
5,392
社区成员
262,731
社区内容
发帖
与我相关
我的任务
Delphi
Delphi 开发及应用
复制链接
扫一扫
分享
社区描述
Delphi 开发及应用
社区管理员
加入社区
获取链接或二维码
近7日
近30日
至今
加载中
查看更多榜单
社区公告
暂无公告
试试用AI创作助手写篇文章吧
+ 用AI写文章