求在treeview中遍历特定文件夹下的文件夹和文件的递归函数?急!多谢!
解决方案 »
- TExcelApplication 操作性能问题
- 急!关于多线程,高手进来分析下,在线等!!!!!!!!!!!!!!!!!!!
- 无题
- 如何在调试时查看 adoquery的sql语句?
- 关于ADOTable4.AppendRecord
- 如何动态的创建线程?
- 能否告诉我一个批量修改unit文件名的方法?????????
- DELPHI通过ODAC执行存储过程传递包括ASCII=0的字符串参数好像有问题!!!
- 各位广州、深圳的同行,现在广州和深圳做delphi开发的待遇怎样
- 请教各位高手,用delphi 作套打 有没有好的控件 ?
- 怎样用delphi在word中画两个不同的表格啊
- delphi 得到存储过程返回值
历遍指定目录下的文件夹和文件倒是可以
function FindFile(sDirectory, ExtName: string): string; //目录名,扩展名
var sr:TSearchRec;
sPath,sFile,Temp:string;
begin
if Copy(sDirectory,length(sDirectory),1)<>'\' then //子目录
sPath:=sDirectory+'\'
else
sPath:=sDirectory;
if FindFirst(sPath+'*.*',faAnyFile,sr)=0 then
begin
Repeat
sFile:=sr.Name;
if (sFile='.') or (sFile='..') then continue;
sFile:=sPath+sr.Name; //递归调用时,路径一定要正确
if ((sr.Attr and faDirectory) <>0 ) then //目录
begin
FindFile(sFile,ExtName); //文件夹
end //文件
else if ((sr.Attr and faAnyFile) = sr.Attr) then
begin
Temp := ExtractFileExt(sFile);
Temp := Copy(Temp,Pos('.',Temp) + 1,Length(Temp) - 1 );
if UpperCase(Temp) = UpperCase(ExtName) then
lst1.Items.Add(sFile);
end;
until FindNext(sr)<>0 ;
FindClose(sr);
end;
end;