如何从指点的文件取出所有文件??急急!!!

yyhyq2000 2003-09-22 11:23:55
比如指点文件在d:/mydoc里面有很多文件,在DELPHI中如何自动的实现取这些文件,

大哥,大姐们,请帮帮忙了。谢谢各位了。
...全文
25 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
zousoft 2003-09-23
  • 打赏
  • 举报
回复
同意楼上
shadowfish 2003-09-23
  • 打赏
  • 举报
回复
用findfirst和findnext循环,就能找出文件夹下所有的文件
qinmaofan 2003-09-22
  • 打赏
  • 举报
回复
查找所有文件的例子

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;
qinmaofan 2003-09-22
  • 打赏
  • 举报
回复
什么意思?
是不是说的列举指定文件夹中的所有文件?
可以使用FindFirst FindNext,递归调用。

5,379

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 开发及应用
社区管理员
  • VCL组件开发及应用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧