Einzelnen Beitrag anzeigen

bernhard_LA

Registriert seit: 8. Jun 2009
Ort: Bayern
1.138 Beiträge
 
Delphi 11 Alexandria
 
#11

AW: delphi unterordner auflisten(2)

  Alt 10. Apr 2012, 09:19
nur zur Info : der gesamte Code, falls jemand intersee hat ....



Delphi-Quellcode:


unit Unit_filerecovery;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Vcl.Menus, Vcl.ExtCtrls, FileCtrl ;

type
  TFileReCovForm = class(TForm)
    Memo1: TMemo;
    MainMenu: TMainMenu;
    File1: TMenuItem;
    Exit1: TMenuItem;
    Panel1: TPanel;
    RootFolderEdit: TEdit;
    SelectRFButton: TButton;
    GetAllFoldersButton: TButton;
    Label1: TLabel;
    procedure GetAllFoldersButtonClick(Sender: TObject);
    procedure Exit1Click(Sender: TObject);
    procedure SelectRFButtonClick(Sender: TObject);
  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
    FOutPutFolder : String;

  end;


procedure FindAllFolders(const aDirList : TStringList; RootFolder: string; Mask: string = '*.*'; Recurse: Boolean = True );

var
  FileReCovForm: TFileReCovForm;

implementation

{$R *.dfm}

procedure TFileReCovForm.SelectRFButtonClick(Sender: TObject);

begin
   selectDirectory('Select a Folder ', '', FOutPutFolder);

   RootFolderEdit.text := FOutPutFolder;
end;

procedure TFileReCovForm.Exit1Click(Sender: TObject);
begin
    close;
end;

procedure FindAllFolders(const aDirList : TStringList; RootFolder: string; Mask: string = '*.*'; Recurse: Boolean = True );
var
  SR: TSearchRec;
begin
  if AnsiLastChar(RootFolder)^ <> '\then
    RootFolder := RootFolder + '\';
  if Recurse then
    if FindFirst(RootFolder + '*.*', faAnyFile, SR) = 0 then
      try
        repeat
          if SR.Attr and faDirectory = faDirectory then
            if (SR.Name <> '.') and (SR.Name <> '..') then
            begin

              FindAllFolders(aDirList , RootFolder + SR.Name, Mask, Recurse);

              if aDirlist.IndexOf(RootFolder + SR.Name) < 0 then aDirlist.Add(RootFolder + SR.Name);
            end;
        until FindNext(SR) <> 0;
      finally
        FindClose(SR);
      end;
end ;

procedure TFileReCovForm.GetAllFoldersButtonClick(Sender: TObject);
var DirStringList : TStringList;
begin

      DirStringList:=TStringList.Create;


      FindAllFolders(DirStringList, FOutPutFolder, ''  ,true );


      memo1.Lines.Assign(DirStringList);


      DirStringList.Free;
end;

end.
  Mit Zitat antworten Zitat