发信人: johnlee4u() 
整理人: (2000-12-05 19:15:19), 站内信件
 | 
 
 
【 在 fengqiaoyepo (青鸟) 的大作中提到: 】
 : 我要用Delphi编一个程序,对某一目录下的所有文件进行批量处理,但不知取得
 : 
 : 一个目录下所有文件名的方法,有那位知道?请不吝赐教,多谢!
 : 另:请转寄一封给我
 :    .......
 
 我自己做的一个函数,你看着改吧。。。
 
 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;
  -- ※ 来源:.月光软件站 http://www.moon-soft.com.[FROM: 202.98.117.225]
  | 
 
 
 |