现在有一个文件夹下存放很多单独的dbf格式的表格,现在我想获得这些文件的名字并赋值给一个listbox  请问如何实现  

解决方案 »

  1.   

    procedure LoadDirFiles(Dir: string; Files: TStrings; bRecursive: Boolean);  procedure DoLoad(Dir: string; Files: TStrings);
      var
        F: TSearchRec;
        hFind: Integer;
      begin
        if (Dir <> '') and (Dir[Length(Dir)] <> '\') then
          Dir := Dir + '\';
        hFind := FindFirst(Dir + '*.*', faAnyFile, F);
        while hFind = 0 do
        begin
          if (F.Name <> '.') and (F.Name <> '..') then
          begin
            if F.Attr and faDirectory <> faDirectory then
              Files.Add(Dir + F.Name)
            else if bRecursive then
            begin
              DoLoad(Dir + F.Name, Files);
              Files.AddObject(Dir + F.Name, TObject(1));
            end;
          end;
          hFind := FindNext(F);
        end;
        FindClose(F);
      end;begin
      Files.BeginUpdate;
      try
        Files.Clear;
        DoLoad(Dir, Files);
      finally
        Files.EndUpdate;
      end;
    end;
    eg:
    LoadDirFiles('放dbf文件夹路径', ListBox.Items, False);
     
      

  2.   

    因为都是Dbf文件,所以这儿改一下
    hFind := FindFirst(Dir + '*.dbf', faAnyFile, F);