比如指点文件在d:/mydoc里面有很多文件,在DELPHI中如何自动的实现取这些文件,大哥,大姐们,请帮帮忙了。谢谢各位了。

解决方案 »

  1.   

    什么意思?
    是不是说的列举指定文件夹中的所有文件?
    可以使用FindFirst FindNext,递归调用。
      

  2.   

    查找所有文件的例子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; 
      

  3.   

    用findfirst和findnext循环,就能找出文件夹下所有的文件