用什么样的方法遍历文件夹内的所有文件?请大侠指教。

解决方案 »

  1.   

    用findfirst,收下看,肯定一堆的。
      

  2.   

    findfirst, findnext, findclose
      

  3.   

    function Find_All_file(var Find_fn:Tstrings):Boolean;
    var
      ALL_F:TSearchRec;
      Err:integer;
    begin
      Application.ProcessMessages ;
      if FindFirst('*.*',$37 ,ALL_F) = 0 then
       begin
         repeat
            if (ALL_F.Attr and faReadOnly) = ALL_F.Attr then
            begin
             Find_fn.Add(All_f.Name); 
            end;
         until FindNext(ALL_F) <> 0;
          FindClose(ALL_F);
       end;
    end;procedure TForm1.Button1Click(Sender: TObject);
    var
      rs:Tstrings;
    begin
      //rs:=TStrings.Create ;
      chdir(self.DirectoryListBox1.Directory);
      Find_All_file(rs);
      memo1.Lines.AddStrings(rs);
    end;end.
      

  4.   

    if FindFirst('路径\*.*', faAnyFile, SearchRec) = 0 then
      begin
        repeat
        begin
        I:=Pos('.',SearchRec.Name);
        EnginName:=SearchRec.Name;
        Delete(EnginName,I,4);
        TreeViewEngin.Items.AddChild(TreeNodeF,EnginName);
        end;
        until (FindNext(SearchRec) <> 0);
      end;
      FindClose(SearchRec);