有什么类的函数或方法可以一次读取整个文件夹下所有文件、文件夹的信息,然后使用其中的文件名字时可以aa[1].name。 像c#中的文件夹实例那样的最好。
我需要大批处理文件,没有针对性。

解决方案 »

  1.   

    能,用循环读取到一个stringlist中
      

  2.   

    用FindFirst 和 FindNext写一个也不难.
    再这么下去,你的CODING能力会退化到只会拖拉控件了.
      

  3.   

    function DeletePath(mDirName: string; Ext: String = '*'): Boolean;
    var
      vSearchRec: TSearchRec;
      vPathName, tmpExt: string;
      K: Integer;
    begin
      Result := true;  tmpExt := Ext;
      if Pos('.', tmpExt) = 0 then
        tmpExt := '.' + tmpExt;  vPathName := mDirName + '\*.*';
      K := FindFirst(vPathName, faAnyFile, vSearchRec);
      while K = 0 do
      begin
        if (vSearchRec.Attr and faDirectory > 0) and
          (Pos(vSearchRec.Name, '..') = 0) then
        begin
          FileSetAttr(mDirName + '\' + vSearchRec.Name, faDirectory);
          Result := DeletePath(mDirName + '\' + vSearchRec.Name, Ext);
        end
        else if Pos(vSearchRec.Name, '..') = 0 then
        begin
          FileSetAttr(mDirName + '\' + vSearchRec.Name, 0);
          if ((CompareText(tmpExt, ExtractFileExt(vSearchRec.Name)) = 0) or (CompareText(tmpExt, '.*') = 0)) then
            Result := DeleteFile(PChar(mDirName + '\' + vSearchRec.Name));
        end;
        if not Result then
          Break;
        K := FindNext(vSearchRec);
      end;
      FindClose(vSearchRec);
    end;