RT

解决方案 »

  1.   

    Delphi的TFileListBox,最简单了。
      

  2.   

    procedure findall(disk,path: String; var fileresult: Tstringlist);
    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 TForm1.Button1Click(Sender: TObject);
    var li:TstringList;
    begin
           li:=TstringList.create;
           try
              findall('',edit1.text,li);
              label1.caption:=inttostr(li.count);  //为所求
           finally 
              li.free;
           end;
    end;
      

  3.   

    赞成 cbdiy() 的写法,查找一个目录或文件夹下的所有文件就是用这种方法!